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

6 REPLIES 6

Hello,

I've been trying to set a placeholder text on CHG table, test plan field in workspace view.

Unfortunately, it is not working with the above onLoad Client script and UI script.

Please assist!

srivallisam
Tera Contributor
Create a onload client script 
function
 onLoad() {
    var field = g_form.getElement("u_name");
    if (field) {
        field.setAttribute('placeholder''Enter your name');
        field.style.color = 'red';
        }
}

This Answer might be helpful, It worked for me