<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.java2java.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>
|