Forum Moderators: open

Message Too Old, No Replies

Email validation not working in Internet Explorer

Script with email address validation doesn't work in Internet Explorer

         

gcan

3:51 pm on Sep 23, 2009 (gmt 0)

10+ Year Member



Hello,

Can somebody help me? I don't understand why my script stops working in Internet Explorer if I include the following lines:
=================================


var email = $("input#email").val();
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter(email)) {
$("label#email_error").show();
$("input#email").focus();
return false;

================================

It works fine with all other browsers.
Thanks.

whoisgregg

4:43 pm on Sep 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A couple things jump out at me. First, there's a missing closing curly brace "}" (but perhaps it exists in the rest of the code). Second, the regular expression isn't wrapped in any kind of quotes. Directly in a call to a function that accepts a regex pattern you skip the quotes, but it might be confusing IE the quotes don't exist when you're storing the regex in a variable?