zed420 Posted November 23, 2008 Share Posted November 23, 2008 Hi All Can some please tell me what is wrong with my code it keeps giving me the error message even with right Email address. Some help will be greatly appreciated. if (myform.email.value != "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/"){ alert("Invalid E-mail Address! Please re-enter."); myform.email.focus(); return (false) } return (true); } Thanks Zed Quote Link to comment Share on other sites More sharing options...
mtoynbee Posted November 24, 2008 Share Posted November 24, 2008 This doesn't look anything like the way I do regular expressions. Try this URL: http://www.w3schools.com/jsref/jsref_obj_regexp.asp Also, remember you need to use the double equals sign for validation. Quote Link to comment Share on other sites More sharing options...
KevinM1 Posted November 24, 2008 Share Posted November 24, 2008 This doesn't look anything like the way I do regular expressions. Try this URL: http://www.w3schools.com/jsref/jsref_obj_regexp.asp Also, remember you need to use the double equals sign for validation. To expand on this, you (the OP) would want to do something like: var regex = new RegExp("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/", "gi"); if(!regex.test(myform.email.value)) { alert("Invalid e-mail address!"); myform.email.focus(); return false; } else { return true; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.