The script clears the form input field when the cursor is clicked on it. The script is made universally, it checks the default value and has no effect on the current value. I.e., when you click on the field again, it won’t be cleared.

<script type="text/javascript">
 //A script that clears the form of text when the cursor clicks on it
function doClear(theText) { if (theText.value == theText.defaultValue) { theText.value = "" } }
function doDefault(theText) { if (theText.value == "") { theText.value = theText.defaultValue } }

<p><INPUT type="text" name="textfield" size="40" maxlength="150"
	value="Enter your name"
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like