Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Auto clear default text

Anonymous
Not applicable
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!
1 Reply
_SekharN_
Level 5
Level 5
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.