How to Validate Phone or Mobile Number in Browser Using Javascript and jQuery Full Project For Beginners

 

Welcome folks today in this blog post we will be validating phone number format in browser using javascript and jquery . All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to make an index.html file and copy paste the following code

 

 

 

index.html

 

 

<form id="myForm">
  <input type="text" name="phone" id="phone">
  <input type="submit" name="submit">
</form>

   $('#myForm').on('submit', function() {
      
      var phone = $('#phone').val();
      //alert(phone)
      if (isNaN(phone) || phone.length < 10 || phone.length > 10) {
        alert(phone+" please enter a valid phone number");
        return false;
      }
      else 
      {
        return true;
      }

    });

Leave a Reply