Posted By : Murugan Andezuthu Dharmaratnam
Posted On : 5 February 2015
Keywords : JQuery Fax number validation,Fax number validation using JQuery,Fax number validation,

Validate Fax Number Using JQuery

Fax Number Validation In JQuery Using Regular Expressions

This Jquery Code Check if the Fax number is valid. If the Fax Number is not valid the text is replaced with a message "Invalid Fax Number" in the text Placeholder.

Expected Output

Code Snippet


<html>
<head>
    <script src="http://code4beginner.com/js/jquery.min.js"></script>
    <script type="text/javascript">

        $.fn.isFaxNumber = function (options) {
            intRegex = /^[0-9]{1,10}$/;
            faxNumber = this.val();
            if ((faxNumber.length != 10) || (!intRegex.test(faxNumber))) {
                this.val("");
                this.attr("placeholder", "Invalid Fax Number");
                return false;
            }
            return true;
        };

        function validate() {
            $("#checkFaxNumber").isFaxNumber(this);
            return false;
        }
    </script>
</head>
<body>
    <input type="text" id="checkFaxNumber" value="ASDFG77" />
    <input type="button" onclick="return validate()"  value="Validate"/>
</body>
</html>

Download Sample Code

Click Right Click here and select "save link as" to download Sample Code. Click here To View sample code working



Murugan Andezuthu Dharmaratnam

Murugan is a technology leader with 14 years of hands-on experience in full life cycle systems design, development, implementation, and management. In addition to systems design and development, his core competencies include cloud design and architecture, interactive web applications and websites development, mobile computing, and Healthcare Information Technology. His experience is very diverse with a broad range of technologies within multiple industry settings including private, public, and non-profit. Coupled with his technology expertise, Murugan is a well-organized, result-oriented, and a highly analytical leader with proven track record in developing and implementing very complex systems.