Topic: Form Validation Problem (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=31091" title="Pages that link to Topic: Form Validation Problem (Page 1 of 1)" rel="nofollow" >Topic: Form Validation Problem <span class="small">(Page 1 of 1)</span>\

 
gilbertsavier
Obsessive-Compulsive (I) Inmate

From:
Insane since: Jun 2009

IP logged posted posted 07-02-2009 06:15 Edit Quote

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

IP logged posted posted 07-02-2009 09:51 Edit Quote

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



Post Reply
 
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
 
Your Text:
Loading...
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu