I have a script that goes something like …
[CODE]var input = document.newsletter.email;
if (/^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$/.test(input.value)) {
// email is valid so send it code goes here
}
This code is more elaborate than what I’ve written and works fine … but that’s not why I’m here.
I’m here because I’m trying to configure a totally different <div> element to say something like …
[CODE]var myDiv = document.getElementById(‘someDiv’);
myDiv.onmouseup = new Function(“if (!/^([_a-z0-9-]+)(.[_a-z0-9-]+)*@([a-z0-9-]+)(.[a-z0-9-]+)*(.[a-z]{2,4})$/.test(input.value)) {input.value = input.defaultValue;”);
Note the exclamation point in my second example. Basically I’m trying to say “if the value of the input is NOT a valid email address, reset the input value”.
For some reason, my email checksum works on form submission but not in regards to my second example.
ie – if I type “asdf@” and hit submit, invalid. If I type “asdf@asdf” and hit submit, invalid. If I typed “
Why? How do I fix this?