How to add Ghost Texts on a placeholder

iquita2005
Giga Contributor

Hello Community,

Please how to I add a ghost texts to a place holder? I will like to add some ghost texts to a text box as a form of additional information that will disappear once the user starts to type into the text box.

Thanks

1 ACCEPTED SOLUTION

Which table form do you want this placeholder text to appear in? Write an onLoad Client script for that table and the script is:



function onLoad() {


  u_addPlaceholderAttribute('u_client', 'Testing placeholder \r\n new line \r\n 3rd line \r\n 4th \r\n this is last');


}



Then write a UI script (because this can be used again anywhere) that goes like this:



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


}



The function call (u_addPlaceholderAttribute) in the onLoad client script should be the function name (u_addPlaceholderAttribute) you give in the UI script. Is this what you did? In my example, 'u_client' is the name of the field where I wanted my placeholder.


View solution in original post

5 REPLIES 5

veena_kvkk88
Mega Guru

This should help you. I used this for my requirement.



Support for HTML 5 placeholder attribute


Thanks, I will been struggling with it before I created the post.


This is what I did...



function u_addPlaceholderAttribute(reporting_criteria, hint) {  


  try{  


      var fieldName = g_form.getControl(reporting_criteria).name.toString();  


      if (Prototype.Browser.IE) {  


          fieldName.placeholder = hint;  


      } else {  


          $(fieldName).writeAttribute('placeholder', hint);  


      }  


  } catch(err) {}  


}  





reporting_criteria is the variable name.


I get an error message: "Missing function declaration for onLoad" I have no idea what that means.


Which table form do you want this placeholder text to appear in? Write an onLoad Client script for that table and the script is:



function onLoad() {


  u_addPlaceholderAttribute('u_client', 'Testing placeholder \r\n new line \r\n 3rd line \r\n 4th \r\n this is last');


}



Then write a UI script (because this can be used again anywhere) that goes like this:



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


}



The function call (u_addPlaceholderAttribute) in the onLoad client script should be the function name (u_addPlaceholderAttribute) you give in the UI script. Is this what you did? In my example, 'u_client' is the name of the field where I wanted my placeholder.