entering regular expressions in javascript -
im trying add regular expression ^[a-za-z0-9,.&#-]{1-45}@[a-za-z]{1-45}.[a-z]{3}$ validate email addresses javascript code.
if(email=="" || email==null) { document.getelementbyid("em_error").innerhtml="*you must enter email address"; error=true; return false; } else document.getelementbyid("em_error").innerhtml="";
you can use match
function.
if(email=="" || email==null || !email.match(/^[a-za-z0-9,.&#-]{1-45}@[a-za-z]{1-45}.[a-z]{3}$/,i))
note
please review pattern, because there should longer , shorter tld 3 characters, .museum
, .eu
, .nowanytldcantakenformoney
Comments
Post a Comment