Skip to main content

Command Palette

Search for a command to run...

Jquery Input Mask Phone Number Validation

Published
View as Markdown

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


More from this blog

Techsolutionstuff | The Complete Guide

93 posts

I am Laravel and PHP Developer. I have also Good Knowledge of JavaScript, jQuery, Bootstrap and REST API.