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

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -