ASPForums.Net RSS Feed additions to the content that appears on ASPForums.Net(c) 2019 All rights reserved.Fax Number validation using RegularExpression (Regex) and JavaScript<p>Hi Bhargav,</p> <p>This is the regular expression for fax format like</p> <p>+(country code)-(area code)-(fax number)</p> <pre class="brush: html">var regex = new RegExp(&#34;\\+[0-9]{1,3}-[0-9]{3}\\-[0-9]{7}&#34;);</pre> <p>Or</p> <pre class="brush: html">var regex = new RegExp(&#34;^\\+[0-9]{1,3}-[0-9]{3}-[0-9]{7}$&#34;);</pre> <p><span style="text-decoration: underline;">HTML</span></p> <div class="demo_block"> <pre class="brush: html">&lt;html xmlns=""&gt; &lt;head runat="server"&gt; &lt;title&gt;&lt;/title&gt; &lt;script type="text/javascript"&gt; function ValidateFax() { var regex = new RegExp(&#34;^\\+[0-9]{1,3}-[0-9]{3}-[0-9]{7}$&#34;); 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."); } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;input id="txtFax" type="text" /&gt; &lt;input type="button" onclick="ValidateFax()" value="Validate" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> </div> <p><a class="demo button orange btn btn-red">Demo</a></p> <p>&nbsp;</p>, 06 Aug 2015 08:46:50 GMT