- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2012 08:07 PM
I've created a function to add support for the HTML placeholder attribute. You can use it to include some extra helpful text in input fields:
It's real simple to use - just include a call to the function in an onLoad script with the name of the field/variable and the text you want displayed:
u_addPlaceholderAttribute('short_description', 'Enter a short description of the problem');
I've tested it in Chrome, Firefox and Opera on Windows 7 and it works. Of course it does not work in current version of IE, but it does work in the upcoming IE 10.
Here's the script:
function u_addPlaceholderAttribute(variableName, hint) {
try{
var fieldName = g_form.getControl(variableName).name.toString();
if (Prototype.Browser.IE) {
fieldName.placeholder = hint;
} else {
$(fieldName).writeAttribute('placeholder', hint);
}
} catch(err) {}
}
I've also attached it as an XML export of the function - just remove the ".txt" extension and import it into your instance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2014 01:10 PM
Just setting this answer as correct as the actual thread was not meant as a question and it cannot be changed because it came from the original Community site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2016 11:56 AM
Sorry, but there does not seem to be an easy answer for that because of the use of the TinyMCE editor for HTML fields. You could probably work out some crazy client script to do it, but it is probably not worth it. This might be a workaround though:
You can use the g_form.showFieldMsg() method to add an informational message at the bottom of the variable - GlideForm (g form) - ServiceNow Wiki. Not ideal, but it is something. Just use the variable name for the "input" parameter.
Another workaround would be to use the Help tag/text on the variable.
I've got a client script that will show the Help text and then even hide the "More information" link to pretty it up. I took a quick look on the Community but did not find it. I could look again if you are interested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2016 08:06 PM
This is great! Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 08:16 AM
You are welcome. I don't understand why it is still not supported OOB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2016 01:21 PM
Hi Jim!
This helped me greatly! But, is there a way to have multiple lines in the placeholder text? I have a string field of length 1000, and I want to have a placeholder with multiple lines like this:
[Logo]
[Job Name]
[Task Name]
[Number Range]
[Delivery Date]
The new line character isn't working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2016 02:26 PM
The placeholder spec says "The placeholder text must not contain carriage returns or line-feeds."https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input If you really need something like that, you could use a Form Annotation.