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.

<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 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

 

Featured Post




Follow us
facebooklogo github instagram twitter