Javascript failing in IE, works in firefox

Hi guys

I am having a problem with form validation:

This emailaddress works like a charm in Firefox, but fails in IE, what’s wrong??

acme@acme11.acme.dk

Any other address works fine, like:

acme@acme.dk

Here is my code:

In OnLoad on the form:

f=window.document.forms[0]

In a page called script.js:

function validateRequiredFields( f ){

var checkEmail = new RegExp(“[1]+@([-a-å0-9._])+.[a-å0-9]{2,4}$”,“i”);

for (var i=0; i < f.elements.length; i++){

if (!(checkEmail.test(f.kont_email.value))) {

	alert ("Dette er ikke en valid email-adresse!")

	f.kont_email.focus(); f.kont_email.select();

	return;

}

I think I have confused myself now with all sorts of combinations…

Please help ;o)


  1. -a-å0-9._ ↩︎

Subject: Javascript failing in IE, works in firefox

the code itself looks nice and cross browser, so its probably ‘f’ thats the problem.

how are you setting and passing ‘f’ to these code snippets and functions ?