Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Text defaultValue

The defaultValue property contains the default value specified by the VALUE attribute of the tag. This property is often used to reset forms to their default values. <html>     <head>     <script language="JavaScript">     <!--     function resetForm(){       document.myForm.myText.value = document.myForm.myText.defaultValue;     }     -->     </script>     </head>     <body>     <b>Edit the text in the following text box:</b>     <P>     <form name="myForm">       <input type=TEXT value="hello world" name="myText">       <input type=BUTTON value="Click to Reset" name="myButton"              onClick="resetForm()">     </form>     </body>     </html>