Closed Thread Icon

Topic awaiting preservation: Form Validation Problem Pages that link to <a href="https://ozoneasylum.com/backlink?for=31091" title="Pages that link to Topic awaiting preservation: Form Validation Problem" rel="nofollow" >Topic awaiting preservation: Form Validation Problem\

 
Author Thread
gilbertsavier
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jun 2009

posted posted 07-02-2009 06:15

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

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-02-2009 09:51

Don't see any obvious mistake, have you looked if the error console of decent browsers has anything to say? Have you replayced return validate(this); with alert(validate(this)); just to check you do get false back?

so long,

->Tyberius Prime

« BackwardsOnwards »

Show Forum Drop Down Menu