Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Displaying the value entered in a text field

< html> <head> <title>Displaying the value entered in a text field</title> <script type="text/javascript" language="javascript"> <!-- // onload = function(){     document.MyForm.MyTextField.focus(); } function DisplayValue(){     if(document.MyForm.MyTextField.value!==""){         alert("The value entered was \n" + document.MyForm.MyTextField.value);     }     else{         alert("The text field was empty!\nPlease enter your name.");     } } // --> </script> </head> <body> <form name="MyForm" action="http://www.rntsoft.com/" method="Post" onsubmit="DisplayValue()"> <input type="text" name="MyTextField"/><P>Enter your name</p> <input type="submit" value="Click to Submit"/> </form> </body> </html>