37 Replies · Latest reply on Nov 15, 2017 4:01 PM by Jim Coyne

    Support for HTML 5 placeholder attribute

      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) {
          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.

      *** Please Like and/or tag responses as being Correct.
      And don't be shy about tagging reponses as Helpful if they were, even if it was not a response to one of your own questions ***