How To Validate 10 Digit Mobile Number Using Regular Expression

Websolutionstuff | Jun-15-2020 | Categories : Laravel PHP jQuery

In This small tutorial, I will explain to you how to validate a 10-digit mobile number using regular expressions in laravel or PHP. The Regex validation gives flexibility to users to enter numbers in different formats as per users' requirements. When you are working with form validation at that time You need to restrict users to enter invalid values and users allow only numeric value and enter 10 digits numbers, especially for Indian mobile no validation.

So let's see how to validate 10 digit mobile number using regular expression, regular expression for 10 digit mobile number in javascript, mobile number validation using regex, regex for mobile number, 10 digit phone number validation, phone number regex javascript, jquery phone number validation regex.

You need to copy the below code in your view or HTML file to get the output.

<html>
<head>
    <title>Allow only 10 digit mobile no using regular expression - websolutionstuff.com</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<form>
    <h1>Allow only 10 digit mobile no using regular expression - websolutionstuff.com</h1>
   <div class="col-md-6">
    <label>Phone Number: </label>
    <input class="form-control" type="text" name="phone Number" placeholder="Phone Number" minlength="10" maxlength="10" required>
    <br>
    <label>Phone Number: </label>
  	<input type="text" class="form-control" name="phone Number" placeholder="Phone Number" pattern="[1-9]{1}[0-9]{9}"  required ><br>
    <button type="submit" class="btn btn-success">Submit</button>
  </div>
</form>
</body>
</html>

In the above example I have used 2 text box, In first text box we have added min and max attributes of HTML to allow 10 numbers or any value, but in the second example, I have added pattern attribute it will help you to restrict alphabet or special character in the textbox and only allow 10 digits numeric value.

 

 

mobile validation

 

mobile validation rex

 


You might also like:

Recommended Post
Featured Post
Laravel 9 Toastr Notifications Example
Laravel 9 Toastr Notifications...

In this tutorial, I will show you laravel 9 toastr notifications example. Using toastr.js you can display a success...

Read More

Feb-23-2022

How To Send Email In Laravel 9 Using Mailtrap
How To Send Email In Laravel 9...

In this article, we will explore the process of sending emails in Laravel 9 using Mailtrap. We will delve into how Larav...

Read More

Jul-27-2022

Laravel 9 Two Factor Authentication With SMS
Laravel 9 Two Factor Authentic...

In this article, we will see laravel 9 two-factor authentication with SMS. we will send an OTP SMS to the mobile nu...

Read More

Sep-26-2022

How to Validate Empty Input Field in jQuery
How to Validate Empty Input Fi...

In the dynamic world of web development, form validation is a crucial aspect of creating a user-friendly and error-free...

Read More

Sep-25-2023