Thanks Ben!...and you're right the code is more top heavy than it should be.
-----Original Message----- From: Ben Nadel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 02, 2006 10:02 AM To: CF-Talk Subject: RE: Confirm email Rob, Let me just say that the email validation seems way more complicated that it has to be. I don't think you have to alert the exact problem to people. I feel you can do less checking, and just alert something like "Please enter a valid email address". That just my opinion... But onto the code. My did not come through bold, so I assume this is your code: if (this.email.value!=this.email2.value){ alert("Please make sure email addresses match!"); return false } The problem here is that "THIS" is probably not pointing to the right object. I think in a function, THIS points to the window. What you need it to do is point to the form object. You can do something like: Var objForm = document.forms["FORM_NAME_HERE"]; if (objForm.email.value!=objForm.email2.value){ alert("Please make sure email addresses match!"); return false } Give that a go, see if that works. Additionally, you could pass in the form object to the Email validation function if it is available to what ever the calling code of the emailCheck() method. ........................ Ben Nadel www.bennadel.com -----Original Message----- From: Orlini, Robert [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 02, 2006 9:54 AM To: CF-Talk Subject: OT: Confirm email I have some JavaScript I inherited from another programmer. I admit I'm not too good w/JavaScript. It checks email addresses for consistent things such as proper punctuation. I wanted to add some code to confirm an email address by entering it twice in two fields email and email2. Here is the entire code, plus my addition (in bold) towards the bottom which doesn't seem to work. I made sure all the cases are correct on the fields. The confirm worked before. Any suggestions would be greatly appreciated. Thank you as always! Robert O. HWW <script language="JavaScript"> function emailCheck (emailStr) { var emailPat=/^(.+)@(.+)$/ var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]" var validChars="\[^\\s" + specialChars + "\]" var quotedUser="(\"[^\"]*\")" var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/ var atom=validChars + '+' var word="(" + atom + "|" + quotedUser + ")" var userPat=new RegExp("^" + word + "(\\." + word + ")*$") var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$") var matchArray=emailStr.match(emailPat) if (matchArray==null) { alert("Email address format seems incorrect (check @ and .'s)") return false } var user=matchArray[1] var domain=matchArray[2] if (user.match(userPat)==null) { alert("The username doesn't seem to be valid.") return false } var IPArray=domain.match(ipDomainPat) if (IPArray!=null) { for (var i=1;i<=4;i++) { if (IPArray[i]>255) { alert("Destination IP address is invalid!") return false } } return true } var domainArray=domain.match(domainPat) if (domainArray==null) { alert("The domain name doesn't seem to be valid.") return false } var atomPat=new RegExp(atom,"g") var domArr=domain.match(atomPat) var len=domArr.length if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) { alert("The address must end in a three-letter domain, or two letter country."); return false } if (len<2) { var errStr="This address is missing a hostname!" alert(errStr) return false } { if (this.email.value!=this.email2.value){ alert("Please make sure email addresses match!"); return false } return true; } </script> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239250 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54