...
Javascript, jQuery, Tutorials

International phone number validation using jquery

06 February 2019

A way to check whether a phone number is correct with and without country code. Phone number with (+) or with (-), with space between numbers, different lengths of numbers. Below the way to validate any phone number of any country using jquery code :

Jquery international phone number validation

<input type="text" id="phone" name="phone"/>
<script>
     $("#phone").blur(function () {
        var regexp = /^[\s()+-]*([0-9][\s()+-]*){6,20}$/
        var no = $("#phone").val();
        if (!regexp.test(no)&& no.length<0) {
            alert("Invalid phone number");
        }
    });
</script>

Leave a Comments