I have a page with a form. One function checks that all fields are filled out and another checks the email field syntax. These functions work in regards to finding missing info or bad email syntax, but now it seems it's not getting submitted when you click the submit button and the redirect isn't working either (also it clears the form when you click the button). Can anyone tell me why? This is one of my first forays into js.
the page can be see/tested here:
http://www.clubspaces.com/signuptest.htm
here is the relevant javascript:
and this is what I have in the opening form tags:Code:function emailCheck(emailStr) { // checks if the e-mail address is valid var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/; var matchArray = emailStr.match(emailPat); if (matchArray == null) { alert("Your email address seems incorrect. Please try again (check the '@' and '.'s in the email address)"); return false; } // make sure the IP address domain is valid var IPArray = matchArray[2].match(/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/); if (IPArray != null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Your email destination IP address is invalid!"); return false; } } } return true; } function validate_form() { var message="Please complete the following: \n------------------------------------------------\n"; var noerrors=message; if (document.getElementById('template').value == "") { message=message + "Please choose a template for your site! \n"; } if (document.getElementById('clubtype').value == "") { message=message + "Please tell us what type of club you have! \n"; } if (document.signup.company.value == "") { message=message + "Please choose a name for your club! \n"; } if (document.signup.first_name.value == "") { message=message + "Please fill in your first name! \n"; } if (document.signup.last_name.value == "") { message=message + "Please fill in your last name! \n"; } if (document.signup.email.value == "") { message=message + "You must provide us with an email address! \n"; } if (document.signup.phone.value == "") { message=message + "Please fill in your phone number! \n"; } if (document.signup.city.value == "") { message=message + "Please fill in your city of residence! \n"; } if (document.signup.state.value == "") { message=message + "Please fill in your state of residence! \n"; } if (document.signup.country.value == "") { message=message + "Please fill in your country of residence! \n"; } if (document.getElementById('numbers').value == "") { message=message + "Please fill in the number of members you have! \n"; } if (document.getElementById('refer').value == "") { message=message + "Please tell us how you found us! \n"; } if (!document.signup.tac.checked){ message=message + "You must agree to the Terms and Conditions before proceeding! \n"; } if(message==noerrors){ return true; } else{ alert(message); return false; } } function OnSubmitCheck() { var one = emailCheck(emailStr); // change functionOne() to onsubmit function name var two = validate_form(); // change functionTwo() to onsubmit function name if((one == false) || (two == false)) { return false; } return true; }
Code:<form name="signup" method="post" action="" onsubmit="return OnSubmitCheck();"> <input type="hidden" value="http://www.clubspaces.com/welcome.htm" name="redirect" />



Maybe I'll test it out another day.
Bookmarks