簡體   English   中英

使用 TextBoxFor 屏蔽電話號碼

[英]Masking phone number using TextBoxFor

我想使用 html helpers (TextBoxFor) 屏蔽電話號碼

有我的代碼

  Model :
        [Required(ErrorMessageResourceType = 
         typeof(ProcRec.Ressources.Candidat.ErreurValidation),
         ErrorMessageResourceName = "num_tel_obligatoire")]
         [RegularExpression(@"[0][6]\-\d{2}\-\d{2}\-\d{2}\-\d{2}$",
        ErrorMessageResourceType =   
        typeof(ProcRec.Ressources.Candidat.ErreurValidation),
         ErrorMessageResourceName = "num_tel_faux")]   
         public string num_tel { set; get; }

看法 :

     <script type="text/javascript">
      jQuery(function($){
        $("#date").mask("99/99/9999");
       $("#num_tel").mask("(999) 999-9999");
       $("#tin").mask("99-9999999");
       $("#ssn").mask("999-99-9999");
      });

        </script>

       <td>@Html.LabelFor(model => model.num_tel)</td>
       <td>@Html.TextBoxFor(model => model.num_tel)</td>

驗證工作

但說到面具,我什么也得不到

他們是我得到的結果

http://postimg.org/image/gm1ygs6fn/

. . . . . . .

我找到了解決方案。
問題是我沒有安裝jQuery.MaskedInput插件。

要安裝jQuery.MaskedInput ,請在包管理器控制台中運行以下命令:

PM> Install-Package jQuery.MaskedInput -Version 1.3.1 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM