Form Validator - Prevent submit if certain form fields empty
Posted: Tue Mar 15, 2005 6:43 am
Hi,
I need to validate a form when the user hits submit.
Basically I want to say that if certain fields on the form have a value of " " then display a message box and prevent the form being submitted to the ASP file ELSE submit the form normally.
Now I came up with something but its not working because when I hit submit with the fields blank its being sent to the process.asp file with not message box appearing.
What is wrong with what I am doing?
In the header I put this,
In the body I put this,
Any ideas?
I need to validate a form when the user hits submit.
Basically I want to say that if certain fields on the form have a value of " " then display a message box and prevent the form being submitted to the ASP file ELSE submit the form normally.
Now I came up with something but its not working because when I hit submit with the fields blank its being sent to the process.asp file with not message box appearing.
What is wrong with what I am doing?
In the header I put this,
Code: Select all
function checkIt(f)
{
if (f.elementsї'Field1name'].value=="e;"e; && f.elementsї'Field2name'].value=="e;"e;)
{
alert('You have not specified the products you wish to order please go back to step 2');
return false;
}
return true;
}In the body I put this,
Code: Select all
<form method="e;post"e; action="e;process.asp"e; name="e;sForm"e; onSubmit="e;return checkIt(this);"e;>
...