Sometime we have text fields with default value like “Please enter you first name”, “Please enter you phone number” etc. We want to clear this default text when user click on the field and if user do not give any input the it will put the default value again.
Javascript code:
function clearValue ( field ) {
if ( field.defaultValue == field.value ) field.value=”;
else if ( field.value == ” ) field.value= field.defaultValue;
}
Use:
<input type=”text” name=”mobile” value=”Phone/Mobile Number” onFocus=”clearValue(this)” onBlur=”clearValue(this)”/>
Download Source Code: click here. (Unzip this zipped file, open clearText.html file with any browser then click on the text field.)
23.764648
90.358043