...

View Full Version : Use of Regular Expressions in Javascript form validation in Mac IE5



scottieoats
07-10-2004, 12:17 PM
Does anyone know of any problems in how IE5+ on the Macintosh handles regular expressions? I am using a function to check form fields before a POST submission. This works fine on Windows on IE5+ and Netscape 7 and works fine on Mac on Netscape 7 and Safari, but not on IE5.x. THe function which seems to break the app is:

<pre>
function isValidEmail(fieldName) {
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(isEmpty(fieldName)) {
return false;
} else {
if(!eval("filter.test(" + fieldName + ".value)")) {
return false;
} else {
return true;
}
}
}
</pre>
isEmpty() is a custom method checking for an empty form field.

I'm not an expert on Regular Expressions, and the filter I've declared is copied



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum