US FAX NUMBER AUTO FORMAT - CAN ANYONE HELP ME PLEASE?

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
 1642  View(s)
Ratings:
Rate this:

Hi Expert!

I have one textbox in my MVC 4 project. In this textbox user entered Fax number of US format. I want to auto set US format Fax number during entered or after leave the textbox.

US format Fax number as following

+1-123-5695847

Please help me!

Thanks in advance!

  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: US Fax Number auto format - can anyone help me please?

    Hi Jayden!

    You could try following line of code

    <script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.maskedinput.js" type="text/javascript"></script>
    <script type="text/javascript">
        jQuery(function ($) {
            $("#fax").mask("+1-"+"999-9999999");
        });
    </script>

    @Html.TextBox("fax", null)

    Note:
    "jquery-1.7.1.min.js" provided by MVC application
    "jquery.maskedinput.js" you can download from following link

    https://raw.github.com/digitalBush/jquery.maskedinput/1.3.1/dist/jquery.maskedinput.min.js

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!