Fax Number validation using RegularExpression (Regex) and JavaScript

Last Reply on Aug 06, 2015 08:46 AM By dharmendr

Posted on Aug 06, 2015 07:52 AM

any one send regular expression for fax validation.


Posted on Aug 06, 2015 08:46 AM Modified on on Aug 06, 2015 09:25 AM

Hi Bhargav,

This is the regular expression for fax format like

+(country code)-(area code)-(fax number)

var regex = new RegExp("\\+[0-9]{1,3}-[0-9]{3}\\-[0-9]{7}");


var regex = new RegExp("^\\+[0-9]{1,3}-[0-9]{3}-[0-9]{7}$");


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript">
        function ValidateFax() {
            var regex = new RegExp("^\\+[0-9]{1,3}-[0-9]{3}-[0-9]{7}$");
            var fax = document.getElementById("txtFax").value;
            if (fax != '') {
                if (regex.test(fax)) {
                    alert("Fax no is valid");
                } else {
                    alert("Fax no is invalid");
            } else {
                alert("Enter Fax no.");
    <form id="form1" runat="server">
        <input id="txtFax" type="text" />
        <input type="button" onclick="ValidateFax()" value="Validate" />



I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html