<form
onsubmit="main()"
action="" action names program to send form data to
method="get"
>
<p>
Please enter a number:
<input size="3" />
<input type="submit" /> a submit button is not really needed when there is only 1 input field
</p>
</form>
JavaScript
function main() {
var input = document.forms[0].elements[0].value; using DOM level 0
var number = parseInt(input);
if (isNaN(number)) {
alert("The user entered `" + input
+ "' which cannot be parsed as a number");
} else {
alert("The user entered the number `" + input + "'");
}
}