this seems to have broken the whole function. after implementing it, it was possible to submit a blank field and it would be accepted. per haps i did it wrong?
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;
}
this is the relevant original (not complete) page code fyi:
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(this.email.value);
var two = validate_form();
if((one == false) || (two == false)) {
return false;
}
return true;
}
function revealState(selMenu){
newCo = selMenu.options[selMenu.selectedIndex].value
if (newCo != "US"){
document.getElementById("state-text").style.display = "block";
document.getElementById("state-menu").style.display = "none";
document.getElementById("int-cc-warning").style.display = "block";
}
else{
document.getElementById("state-menu").style.display = "block";
document.getElementById("state-text").style.display = "none";
document.getElementById("int-cc-warning").style.display = "none";
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<table class="CustomPageMainTable" cellSpacing="0" cellPadding="0">
<tr>
<td>
<table class="NavTopMainTable" cellSpacing="0" cellPadding="0" border="0">
<tr>
<td class="NavTopContent"><div id="navtop">
<div class="titlefloat"><span class="headertitle">Simply the <strong>best</strong> tool for managing your club <strong>online</strong>!</span></div>
<a href="index.htm"><img width="218" height="66" border="0" alt="Club Spaces" src="images/logo_cs.gif" /></a></div>
<div id="nav">
<div class="navfloat">
<ul class="navlist">
<li><a href="index.htm" class="navlist">Home</a></li>
<li><a href="services.htm" class="navlist">Services</a></li>
<li><a href="signup.htm" class="navlist">Sign-Up</a></li>
<li class="end"><a href="sponsors.htm" class="navlist">Sponsors</a></li>
</ul>
</div>
<img width="228" height="27" border="0" src="images/navPattern.gif" alt="nav pattern" /></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="CustomPageContent">
<div id="container">
<div class="signup">
<form name="signup" method="post" action="http://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" onsubmit="return (emailCheck(this.email.value) && validate_form()); return false">
<input type="hidden" value="00D500000006qei" name="oid" />
<input type="hidden" value="http://www.clubspaces.com/welcome.htm" name="retURL" />
<span class="page-title">Sign Up</span>
<table width="500" cellspacing="0" cellpadding="5" border="0" class="signupTable">
<tbody>
<tr valign="top">
<td><label for="clubtype">Template Selection:</label></td>
<td><select name="00N50000001I6Xb" title="Template Selected" id="template">
Bookmarks