Reference form element by using the dot notation : Elements : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Elements »

 

Reference form element by using the dot notation

















<html>
<head>
<title>Displaying the value entered in a text field</title>
<script type="text/javascript" language="javascript">
<!-- //
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.navioo.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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Elements