Having a bit of trouble with some basic form validation, basically what is meant to happen is if any of the fields are empty when the user clicks submit, a message comes up in the span ‘eFld1’. At first i thought it was because document.write() had already been run but after adding an alert() to the script that didnt work either so im quite stumped as to whats going on
What am i doing wrong and what should i be doing?
Script in Header
[CODE]
<script type=”text/javascript”>
var errorList1 = “”
var errorList2 = “”
var regForm = document.register
function validateForm() {
if (regForm.uName.value == null) {
alert(‘somethings wrong’)
return false;
}
else {
return true;
}
}
</script>
Form
[CODE]
<form name=”register” method=”post”>
<span id=”eFld1″>
</span>
Name: <br />
<input type=”text” name=”bName” /><br />
Phone: <br />
<input type=”text” name=”bPhone” /><br /><br />
<span id=”eFld2″>
</span>
Name: <br />
<input type=”text” name=”uName” /><br />
Phone: <br />
<input type=”text” name=”uPhone” />
<input type=”submit” onSubmit=”validateForm”/>
</form>
Any help would be appreciated.