How To Validate 10 Digit Mobile Number Using Regular Expression

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

In This small tutorial i will expain you how to validate 10 digit mobile number using regular expression in laravel or php.

The Regex validatation gives flexibility to user to enter numbers in different format as per user's requirments.When you are working with form validation at that time You need to restrict user to enter invalid value and users allow only numeric value and enter 10 digits number specially for indian mobile no validation.

So let's start..

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

    <title>Allow only 10 digit mobile no using regular expression -</title>
    <link rel="stylesheet" href="">
	<script src=""></script>
    <h1>Allow only 10 digit mobile no using regular expression -</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>
    <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>

In above example i have used 2 text box,In first text box we have added min and max attribute of html to allow 10 number or any value, but in second example i have added pattern attribute it will help you to restrict alphabet or special charater in textbox and only allow 10 digit numeric value.


mobile validation


mobile validation rex


Recommended Post
Featured Post