Hi Guys
I have one textbox in my MVC 4 project. In this textbox user entered US phone number. I want to auto set US format phone number during entered or after leave the textbox.
US format phone number as following
Thanks
Home / DeveloperSection / Forums / auto format phone number of united states in MVC 4
Hi Guys
I have one textbox in my MVC 4 project. In this textbox user entered US phone number. I want to auto set US format phone number during entered or after leave the textbox.
US format phone number as following
Thanks
AVADHESH PATEL
09-Mar-2013Hi Royce!
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 ($) {
$("#phone").mask("(999) 999-9999");
});
</script>
@Html.TextBox("phone", 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