Highlighted

Auto clear default text

Avatar

Avatar

_Mel_bush_

Avatar

_Mel_bush_

_Mel_bush_

18-03-2009

I have searched all over to see how this is done. I found one other response to this question, but it was not complete.



Basically what I am wondering is, how do I set up my text field so that there is a default text to signify what the user should type into the box. When the user clicks the text field, this default is removed so they can begin typing.



Thank you!

Replies

Avatar

Avatar

_SekharN_

Avatar

_SekharN_

_SekharN_

20-03-2009

It is easy...........

I would use the following code in "Enter" and "Exit" events....

Let us say the default text in the text field is "Default Text"



//Enter event JavaScript



var curText = this.rawValue;

var defText = "Default Text"



if (curText == defText) {

//when the current text is same as Default text clear the box

this.rawValu = "";

}

//no need of else condition as rest of the logic will be automatically taken care.

/////////////////////////////////////////////



//JS Code for Exit event



var defText = "Default Text";



if (this.isNull) {

this.rawValu = defText;

}

//again no need of else condition as rest of the logic will be automatically taken care.