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 Link to comment https://forums.phpfreaks.com/topic/133944-e-mail-validation-not-working/ 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. Link to comment https://forums.phpfreaks.com/topic/133944-e-mail-validation-not-working/#findComment-697810 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; } Link to comment https://forums.phpfreaks.com/topic/133944-e-mail-validation-not-working/#findComment-697829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.