- 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
06-05-2012 08:08 AM
This is awesome, Jim.
You can also make use of the relatively new "Messages" field on Client Scripts to internationalize this for different languages. For the example given, you'd put the following into the Messages field of the Client Script:
Enter a short description of the problem
Then in the function, add the following as the first line:
hint = getMessage(hint);
Then, if you have localized versions of "Enter a short description of the problem", your users will see them in the proper language.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 04:45 AM
Hey Capa JC, just to be clear, the string that goes into the "Messages" field is the value in the "Key" field from the Messages table, correct? The wiki is not very clear about that. And in fact, the client-side version of getMessage is not documented at all. It appears in a few places, but it is not actually documented per se.
I'm guessing there's something similar to a before display Business Rule that gets the appropriate string from the Messages table and stores it client-side for use by getMessage.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2015 01:16 PM
I'd also be interested in knowing exactly how to use the Messages field--how do you add multiple messages and pull them throughout the script?--as well as what the system benefit is to this approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2020 08:37 PM
Oops, I forgot to "close the loop" with a related post of mine (though the answer--internationalization--was right in