[Javascript] regexp usage

DEV dev at qroute.net
Mon Jan 12 15:35:00 CST 2004


I have found this regexp to validate email;

^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$

How can I use this in a true|false returning function say named isEmail.

I'd like it to be run like this. 

if ( !isEmail(window.document.Email.value) )
{
    alert('Your email does not seem right')
    return false;
}


function isEmail(input)
{
    // ^[\w-]+(?:\.[\w-]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7}$
}



More information about the Javascript mailing list