hello everyone:
I tried to use a counter to count how many elements on the form
passed validation test. (if all the elements passed validation test,
then submit the form. Otherwise don't submit the form)
But counter will not increment correctly. I think the cause is due to
the value of boolean variable validatedOK didn't get updated correctly!
In my switch statement: cases for "undergrad_account" and
"grad_account " didn't return boolean variable back to switch
statement, the associated validation function are called by using
onclick event handler. After the break statement, boolean variable
validatedOK remains 'true', the counter keeps increasing regardless if
checkboxes for graduate students' account being checked or not.
If you have time, please run my code and give me some suggestions
a)how to make it work properly.
b) Is there an alternative approach to validate elements on the form?
I used onSubmit event handler becuase it provides an opportunity to
check most elements on the form and return 'false' so the form won't
submit.
I appreciate your help!
HTML code:
<body onload="document.account_form.fname.focus()">
<form name="account_form" id="account_form" action="" method ="post"
onSubmit="return form_validation()">
First Name: <input type="text" name="fname" id="fname"
value="" maxlength="20"><br /><br />
Last Name: <input type="text" name="lname"
id="lname" value="" maxlength="20"><br /><br />
age: <input type="text" name="age" id="age" value=""
maxlength="3"><br /><br />
<input type="radio" name="gender" id="maleR" value="male" />Male <br
/><br />
<input type="radio" name="gender" id="femaleR" value="female" />Female
<br /><br />
<!-- selection list ----------------------->
<select name="departments" id="departments">
<option value="none">select your department</option>
<option value="art">Arts</option>
<option value="bio">Biology</option>
<option value="cs">Computer Science</option>
<option value="eng">English</option>
<option value="math">Mathematics</option>
<option value="geology">Geology</option>
<option value="history">History</option>
<option value="physics">Physics</option>
</select><br /><br />
Email <input type="text" name="email" id="email" size="30"
maxlength="30" /><br /><br />
Phone Number&nbsp;&nbsp;<input type="text" name="phone_num"
id="phone_num" size="14" maxlength="14" />
(enter a phone number like 4084445566)<br /><br />
<!--
account selection - undergradu