- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2017 08:59 AM
Hi,
How can I add shadow text for ServiceNow forms? I dont see any option to add it in the Studio - Forms.
I'm looking for something like this (In the text filed - "Optional - Enter Phone No").
Any workaround or help is highly appreciated Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 08:22 PM
By default, ServiceNow blocks updating DOM objects in scoped applications.
You need to add below system property and set it to false.
glide.script.block.client.globals
and use below function to set placeholder text in on load script.
u_addPlaceholderAttribute('field_name', 'YYYY-MM-DD');
function u_addPlaceholderAttribute(variableName, hint) {
var fieldName;
try{
if(variableName.indexOf('phone') >= 0)
{
fieldName = g_form.getControl(variableName).name.toString();
fieldName = 'disp_'+fieldName;
}
else{
fieldName = g_form.getControl(variableName).name.toString();
}
if (Prototype.Browser.IE) {
fieldName.placeholder = hint;
} else {
$(fieldName).writeAttribute('placeholder', hint);
}
} catch(err) {}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 09:57 AM
Hello Jim,
additional_info field is of type String.
ServiceNow version is Helsinki.
I'm using windows 10, Chrome / IE browser. I tried with info messages as well.
Here is what I see: (It's displaying the before placeholder text message). But not the one after that. I believe it is somehow erring out at that step.
Checked client log -
No clue why it didn't execute the next 2 statements.
Regards,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 10:15 AM
Silly question - are there any spaces in the "Additional info" field text box? Maybe the field is not truly empty and so the placeholder text is not visible? What happens when you create a new record?
If you are able to take a look at the source HTML code (with whatever tool), can you see the placeholder attribute/text?
What happens when you replace your line 12 with the following (don't leave that in your production code though):
} catch(err) {
alert(err.toString());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 11:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 11:49 AM
Does it work if you use $$ instead?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2017 12:34 PM
try $j ?