Switch to full style
HTML,DHTML,Javascript,XML,CSS
Post a reply

Form Validation Problem

Mon Aug 17, 2009 1:16 pm

Hi,
I am trying to validate a form, and am getting the error messages as needed, but it submits the form anyway.

Here is the Java:

function validate (form){

var returnValue = true;

var email = CSLavRequestForm.email.value;
var phone = CSLavRequestForm.phoneNumber.value;
var groupName = CSLavRequestForm.workshopName.value;

if (email.length < 6){
returnValue = false;
alert("Please Enter Valid email");
CSLavRequestForm.email.focus();
}
if (phone.length < 10){
returnValue = false;
alert("Please Enter Valid Phone Number");
CSLavRequestForm.phone.focus();
}
if (groupName.length < 3){
returnValue = false;
alert("Please Enter Valid Workshop/Region");
CSLavRequestForm.groupName.focus();
}

return returnValue;
}
</script>

and the form line in the html:

<form onsubmit="return validate(this);" action="/cgi-sys/formmail.pl" method="post" name="CSLavRequestForm" id="CSLavRequestForm" >


I am stuck! Benn working on this for way too long



Post a reply
  Related Posts  to : Form Validation Problem
 Form Validation Problem     -  
 AJAX form validation     -  
 complete registration form with validation     -  
 I'm having a problem creating a Javascript form. Whats wrong     -  
 php login form (sign-in form)     -  
 DNS Validation     -  
 XML validation against DTD     -  
 What will be validation for Zip code ?     -  
 date validation in asp     -  
 validation using JavaScript     -