Validating DataAssist Insert Form
I'm trying to validate several items in my insert data form. But when the validation error window pops up and I click okay the form submits. Obviously I don't want it to do that until all items are validated. Here is the javascript I'm using:
<script LANGUAGE="JavaScript">
<!--
function ValidateForm(form){
ErrorText= "";
if ( form.merchant.value == "") { alert ( "Merchant Name is a required field" ); return false; }
if ( form.contact.value == "") { alert ( "Contact Name is a required field" ); return false; }
if ( form.metro.selectedIndex == 0 ) { alert ( "You must choose a Metropolitan Area." ); return false; }
if ( form.terms.checked == false ) { alert ( "Please check the Terms & Conditions box." ); return false; }
if (ErrorText= "") { form.submit() }
}
-->
</script>
On the form submit button I have:
<input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="images/SubmitButton.jpg" onClick="ValidateForm(this.form);" />
I'm also trying to check to see if there is a duplicate entry in the email field of my form and confirm the password. Any suggestions?
Thank You.