---
title: "How to validate phone numbers using jQuery?"  
description: "How to validate phone numbers using jQuery?"  
author: "Utpal Vishwas"  
published: 2023-05-11  
updated: 2023-05-11  
canonical: https://www.mindstick.com/forum/158284/how-to-validate-phone-numbers-using-jquery  
category: "jquery"  
tags: ["jquery", "jquery selectors", "jquery validate", "form validation"]  
reading_time: 2 minutes  

---

# How to validate phone numbers using jQuery?

How to [validate](https://www.mindstick.com/forum/1490/what-is-better-solution-for-validate-form-textboxs-value) [phone](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) numbers using jQuery?

## Replies

### Reply by Aryan Kumar

There are many ways to validate phone numbers using jQuery. Here are a few examples:

- **Use the validate-phone plugin.** The validate-phone plugin is a jQuery plugin that can be used to validate phone numbers. The plugin supports a variety of different phone number formats, including US, UK, and Canada. For example, the following code would validate a US phone number:

Code snippet

```plaintext
$(document).ready(function() {
  // Validate the form
  $("#myForm").validate({
    rules: {
      phone: {
        required: true,
        validate-phone: {
          country: "US"
        }
      }
    }
  });
});
```

- **Use a regular expression.** You can also use a regular expression to validate phone numbers. For example, the following code would validate a US phone number:

Code snippet

```plaintext
$(document).ready(function() {
  // Validate the form
  $("#myForm").validate({
    rules: {
      phone: {
        required: true,
        regexp: /^\(1\)([2-9]\d{2}-[0-9]{3}-[0-9]{4}|[0-9]{10})$/
      }
    }
  });
});
```

- **Use a custom validation function.** You can also create your own custom validation function to validate phone numbers. For example, the following code would validate a US phone number:

Code snippet

```plaintext
$(document).ready(function() {
  // Validate the form
  $("#myForm").validate({
    rules: {
      phone: {
        required: true,
        custom: function(value) {
          // Check if the value is a valid US phone number
          var re = /^\(1\)([2-9]\d{2}-[0-9]{3}-[0-9]{4}|[0-9]{10})$/;
          return re.test(value);
        }
      }
    }
  });
});
```

These are just a few examples of how to validate phone numbers using jQuery. There are many other ways to validate phone numbers, and the best approach will vary depending on your specific needs.


---

Original Source: https://www.mindstick.com/forum/158284/how-to-validate-phone-numbers-using-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
