javascript - How can i validate and alert if the phone has incorrect input? -


the phone number , email must valid.

this basic popup contact form without phone number validation. validate phone number. heard regex i´m not sure how implement in code.

since don´t understand javascrip yet hope can me.

<form action="#" method="post" id="form">      <h2>contact us</h2><hr/>     <input type="text" name="company" id="company" placeholder="company"/>      <input type="text" name="name" id="name" placeholder="name"/>      <input type="text" name="email" id="email" placeholder="email"/>      <input type="text" name="phone" id="email" placeholder="phone"/>      <a id="submit" href="javascript: check_empty()">send</a>  </form>   function check_empty(){     if(document.getelementbyid('company').value == ""      || document.getelementbyid('name').value == ""     ||document.getelementbyid('email').value == ""     ||document.getelementbyid('phone').value == "" ){     alert ("please, fill fields!");     }     else {           document.getelementbyid('form').submit();     } }  //function display popup function div_show(){      document.getelementbyid('abc').style.display = "block"; }  //function check target element function check(e){      var target = (e && e.target) || (event && event.srcelement);       var obj = document.getelementbyid('abc');      var obj2 = document.getelementbyid('popup');       checkparent(target)?obj.style.display='none':null;      target==obj2?obj.style.display='block':null;   }   //function check parent node , return result accordingly function checkparent(t){      while(t.parentnode){          if(t==document.getelementbyid('abc'))             {                  return false              }         else if(t==document.getelementbyid('close'))             {                 return true             }          t=t.parentnode      }      return true  }  


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -