Hi,
I'm trying to write a form that has required fields. When the form is filled out with the required fields missing, I'm trying to have a pop-up that tells them what is missing and then cancels the submission of the form.
At the moment I have the function below linked into the the Submit button like so: <submit onClick="validateForm()">
function validateForm(){
var form_object = document.forms.helpform;
if(form_object.elements.Name.value == ''){
alert('Please enter your name.');
return false;
} else if(form_object.elements.Email.value == ''){
alert('Please enter your email address');
return false;
} else if(form_object.elements.Mobile.value == ''){
alert('Please enter your mobile phone number');
return false;
} else if(form_object.elements.Description.value == ''){
alert('Please enter a description of what you would like us to help you with.');
return false;
}
return true;
}
I have the function in the the head of the document.
The pop-ups work fine, but it doesn't cancel the form from submitting. If anyone has any suggestions, they would be most appreciated
Thanks in Advance