Skip to content
Loading
+3
  • Sourabh Somani
    +2
    https://codepen.io/chriscoyier/pen/PbOEqL
    +2
  • Laxmidhar Sahoo
    +1
    create a function and call in textboxfor in the arguments of htmlargs
    +1
  • Laxmidhar Sahoo
    +1
    hi
    @sourabh 
     
    u are telling about input type
    when the questrion is in textboxfor 
    +1
  • Sanwar Ranwa
    +1
    this may help you 
     
    https://www.codeproject.com/Tips/846537/Input-Masking-with-ASP-NET-MVC
    +1
  • Sourabh Somani
    +1
    When you will do 
    1. Html.TextBoxFor(m => m.Phone)  
    It will generate 
    1. "Phone" name="Phone" type="text" />  
    Now accordingly you can write your javascript.
     
     
    Thats why i am giving you a very simple solution.
    +1
  • Laxmidhar Sahoo
    +1
    the code for textboxfor is
     
    @Html.TextBoxFor(model => model.PhoneNumber, new { htmlAttributes = new { @class = "form-control" ,@id="phone"} })
     
    the jquery I am given bellow u may use javascript
     
    1. @section Scripts{  
    2. "text/javascript" src="/Scripts/jquery-1.8.3.min.js"  charset="utf-8">  
    3.     "text/javascript" src="/Scripts/jquery.maskedinput.min.js">  
    4.       
    5.   
    6.     "text/javascript">  
    7.         $(function () {  
    8.             $("#phone").mask("(999) 999-9999");  
    9.         });  
    10.       
    11. }  
     
    +1