- 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
07-18-2016 07:09 AM
This solution worked for me except when viewing the catalog items in Service Portal. Probably related, the client-side validation doesn't get fired either. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2016 09:44 AM
I'll admit I had not played around with the portal until this morning, and it's got me confused now. None of my Catalog Client Scripts are triggering from within the portal. Not sure what is going on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2016 09:49 AM
Catalog client script must be set to type "both" or "mobile" for them to run in Service Portal, also you must follow the mobile compatible version of the client script API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2016 10:00 AM
Thanks nathanfirth. Looks like the ability to add a placeholder will NOT work until ServiceNow adds a native method to the Mobile GlideForm. Too bad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2016 10:45 AM
The beautiful thing with Service Portal is that you have full access to the widget code and can implement any logic or functionality that's missing. Of course it would be nice if much of this functionality existed out-of-box, but with the majority of cases I find that I can implement the missing functionality in just a few hours and don't have to wait for it to eventually ship... if it even ever does. A perfect example of this is we just did a full shopping cart implementation on Service Portal which is another major feature missing from the portal service catalog.