Validate email address in a textfield form using javascript

Get the text input from an html form and validate if it is an email address format


      //returns true if email is valid
    function validEmail(email){
      var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
      return regex.test(email);

Leave a Reply

Your email address will not be published. Required fields are marked *