Hi,
I was wondering if someone can take a look at the code below and help me to get it to work.
What I'm trying to do is validate a email and password that gets submitted from a form by checking for WHOLE Words instead of just single characters.
Any help would be great.
Thanks,
Larry
I was wondering if someone can take a look at the code below and help me to get it to work.
What I'm trying to do is validate a email and password that gets submitted from a form by checking for WHOLE Words instead of just single characters.
Code:
<script> <!-- Check the from is filled in correctly before submitting --> <!-- Hide from older browsers... //Function to check form is filled in correctly before submitting var badPass=new Array("Pass","Password") var badEmail=new Array("yahoo","aol","msn","hotmail") function CheckForm () { var errorMsg = ""; var errorMsgLong = ""; { var theInfo=document.frmRegister.Password.value; var isGood=false; var curChar; for (i=0; i<theInfo.length; i++) { curChar = theInfo.charAt(i); for (j=0; j<badEmail.length; j++) { if (curChar == badEmail[j]) { isGood = true; break; } } if (isGood) break; } if (isGood) { } else { errorMsg += "\nE-mail Host \t- You E-mail Address Must Be From A Valid Place Of Business\. Yahoo \, MSN \, Hotmail \, Etc\.\n\t\tIs Not Acceptable\."; } } { var theInfo=document.frmRegister.Password.value; var isGood=false; var curChar; for (i=0; i<theInfo.length; i++) { curChar = theInfo.charAt(i); for (j=0; j<badPass.length; j++) { if (curChar == badPass[j]) { isGood = true; break; } } if (isGood) break; } if (isGood) { } else { errorMsg += "\nPassword \t- You You Must Have A Unique Password\.\n\t\tPass \, Password \, and Common Words Are Not Acceptable\."; } } //If there is a problem with the form then display an error if ((errorMsg != "") || (errorMsgLong != "")){ msg = "_____________________________________________________________________\n\n"; msg += "Your Registration has not been submitted because there are problem(s) with the form.\n"; msg += "Please correct the problem(s) and re-submit the form.\n"; msg += "_____________________________________________________________________\n\n"; msg += "The following field(s) need to be corrected: -\n"; errorMsg += alert(msg + errorMsg + "\n" + errorMsgLong); return false; } } // --> </script>
Thanks,
Larry
Comment