Jquery Input Mask Phone Number Validation

Today we will see jquery input mask phone number validation,using jquery input mask we can validate diffrent type of phone/mobile number with diffrent country code. here we are using jquery inputmask js for validate phone number using jquery input mask.

So, let's see how to validate phone number using Jquery Input Mask,

<html>
<head>
    <title>Jquery Input Mask Phone Number Validation - techsolutionstuff</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>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.inputmask/3.3.4/jquery.inputmask.bundle.min.js"></script>
</head>
<body>
  
<div class="container" style="border:1px solid red; padding: 0px 20px 20px 20px; margin-top: 20px;">
    <h1>Jquery Input Mask Phone Number Validation - techsolutionstuff.com</h1>
  	<br>
    <strong>Phone Number:</strong>  
    <input type="text" name="phone" class="phone_number_1 form-control" value="9999999999">
  	<br>
    <strong>Phone Number:</strong>  
    <input type="text" name="phone" class="phone_number_2 form-control" value="9999999999">
  	<br>
    <strong>Phone Number:</strong>  
    <input type="text" name="phone" class="phone_number_3 form-control" value="91 9876543210">
  
</div>
  
<script>
    $(document).ready(function(){
        $('.phone_number_1').inputmask('(999)-999-9999');
        $('.phone_number_2').inputmask('(99)-9999-9999');
        $('.phone_number_3').inputmask('+99-9999999999');
    });
</script>
  
</body>
</html>

In above code i have added inputmask in jquery for diffrent validation.

jquery_input_mask_phone_number_validation_output

 


You May Also Like :

techsolutionstuff

Techsolutionstuff | The Complete Guide

I'm a software engineer and the founder of techsolutionstuff.com. Hailing from India, I craft articles, tutorials, tricks, and tips to aid developers. Explore Laravel, PHP, MySQL, jQuery, Bootstrap, Node.js, Vue.js, and AngularJS in our tech stack.

RECOMMENDED POSTS

FEATURE POSTS