Can someone rewrite this javascript. The problem now is that 1 regex is only working( that one from email)
earlier question: link I got advice here but I think I put it not good in my code
function checkform ( form )
{
var rex = /[^a-z]/i;
var regex = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!regex.test(form.email.value))
{
alert( "Please enter youre valid email address." );
form.email.focus();
return false ;
}
if (rex.test(form.name.value))
{
alert( "Please enter your name. no numbers or #$^& things allowed)." );
form.name.focus();
return false ;
}
return true ;
}
/[^a-z]/ipattern should match any non-alpha character. What input are you using to test?([a-zA-Z0-9]{2,4})+tld-block, as it would allow you to basically have any tld suffix larger than 2 characters. But aside from that there should not be a problem. Btw, even though your RegExp should suite most needs, just in case you want to take a look at the real email validation RegExp you may do so at this page