

// Email Validation. Written by PerlScriptsJavaScripts.com

function check_email(e) {
ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";

for(i=0; i < e.length ;i++){
if(ok.indexOf(e.charAt(i))<0){ 
return (false);
}	
} 

if (document.images) {
re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
if (!e.match(re) && e.match(re_two)) {
return (-1);		
} 

}

}






function check_form(f) { // f is the form (passed using the this keyword)
if(f.fname.value.length < 1){
alert("Oops! Please enter a first name.");
f.fname.focus(); // put the prompt in the name field 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.fname.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}


if(f.lname.value.length < 1){
alert("Oops! Please enter a last name.");
f.lname.focus(); // put the prompt in the name field 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.lname.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}


if(f.troopname.value.length < 1){
alert("Oops! Please enter a troop.");
f.troopname.focus(); // put the prompt in the name field 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.troopname.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}

if(!check_email(f.email.value)){
alert("Oops! Please verify that your e-mail address is correct.");
f.email.focus(); 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.email.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}

if(f.password.value.length < 6){
alert("Oops! Please enter a password at least 5 characters long.");
f.password.focus(); // put the prompt in the name field 
// if the browser is Netscape 6 or IE
if(document.all || document.getElementByID){
// change the color of text field
f.password.style.background = "yellow";
}
// make sure the form is not submitted
return false;
}
}