Validating Phone Numbers Using Javascript

前端 未结 9 2197
刺人心
刺人心 2021-01-06 00:41

I\'m working on a web form with several fields and a submit button. When the button is clicked, I have to verify that the required text boxes have been filled in and that th

9条回答
  •  [愿得一人]
    2021-01-06 01:00

    To validate Phone number using regular expression in java script.

    In india phone is 10 digit and starting digits are 6,7,8 and 9.

    Javascript and HTML code:

    function validate()
    {
      var text = document.getElementById("pno").value;
      var regx = /^[6-9]\d{9}$/ ;
      if(regx.test(text))
        alert("valid");
      else
        alert("invalid");
    }
    
        
            JS compiler - knox97
      
      
       
        

提交回复
热议问题