Self emptying Text Box Want some initial text in a text box on a form, but want it to disappear as soon as the user clicks to enter data? Click the box above to try it. Here’s how to do it. In your code for the Input Box add : onFocus="if (this.value==this.defaultValue) this.value='';" onBlur="if ((1) && (this.value=='')) this.value=this.defaultValue;" eg: <input type="text" value="Enter your name" name="fName" onFocus="if (this.value==this.defaultValue) this.value='';" onBlur="if ((1) && (this.value=='')) this.value=this.defaultValue;">
Check Password Entry Want to check if two passwords entered on a form are the same before sending the data? Enter 2 different passwords in the boxes above and click submit to try it. If you enter 2 identical passwords the form will be submitted (In this example back to this page.) Here’s how to do it. In your code for the 2nd Input Box add : onBlur="if ((this.value != this.form.password1.value)) alert('The passwords are not the same.');" (where password1 is the name of the first input box and password the second) eg: <form action="" method="post" target="_self" enctype="application/x-www-form-urlencoded"> <input type="submit" name="submit" value="Submit" > Password :<input type="password" name="password1" size="9" style="width:80px;" value="" > Confirm Password :<input type="password" name="password" size="9" style="width:80px;" value="" onBlur="if ((this.value != this.form.password1.value)) alert('The passwords are not the same.');"> </form> In the sample above we have also added form validation to ensure boxes are not blank. Total Form Validation examples are available to members only. (Register and Log On to learn more.)