please help me to fill gaps

<html>
<head>
<title>Gaps</title>
<script langauge="javascript">
function start()
{
__A________________________________________________;
}

function validate( event )
{
if ( B_____{
event.preventDefault();
C__________________;
alert( "Wrong format for age!" );
}
}

</script>
</head>
<body onload="start()">
<form method="post" action="/cgi-bin/prob3.cgi">
<p>
Your age:
<input name="age" type="text">
<p>

<input type="reset">
<input type="submit" value="Submit">
</form>
</body>
</html>

A--Make the function validate a listener for the submit event(for the form element).
B-- An expression that is true if the value of the textbox does not contain one to three digits.
C--Select the text box.
[1028 byte] By [zhshqzyc] at [2007-11-20 3:17:10]
# 1 Re: please help me to fill gaps
What exactly is your problem? Are you trying to get someone here to code this for you?

To validate on submit use...
<form onsubmit="return validatefunction()" ...>
To check how many characters/digits are in a string use length() (http://www.w3schools.com/jsref/jsref_length_string.asp).

To select a DOM Element item use focus() (http://www.w3schools.com/htmldom/met_anchor_focus.asp).
PeejAvery at 2007-11-8 0:41:28 >
# 2 Re: please help me to fill gaps
Is this right?

A: <form onsubmit="validate()">
B: =~ /^d{1,3}$/
C: document.getElementsByTagName("form").focus()

What is the left side in the expression B?

Thank you very much!
zhshqzyc at 2007-11-8 0:42:25 >
# 3 Re: please help me to fill gaps
Is this right?
I cannot tell you what is right exactly until you answer my question of what exactly you are trying to do.

You need to use return and not just validate(). Without the return the form will process without true validation.

You want to focus an element, not the form.
document.getElementById("HTML ELEMENT ID").focus();
PeejAvery at 2007-11-8 0:43:22 >