Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用TextBoxFor屏蔽电话号码_Javascript_Jquery_Asp.net Mvc_Jquery Mask - Fatal编程技术网

Javascript 使用TextBoxFor屏蔽电话号码

Javascript 使用TextBoxFor屏蔽电话号码,javascript,jquery,asp.net-mvc,jquery-mask,Javascript,Jquery,Asp.net Mvc,Jquery Mask,我想使用html助手(TextBoxFor)屏蔽电话号码 这是我的密码 Model : [Required(ErrorMessageResourceType = typeof(ProcRec.Ressources.Candidat.ErreurValidation), ErrorMessageResourceName = "num_tel_obligatoire")] [RegularExpression(@"[0][6

我想使用html助手(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>

jQuery(函数($){
美元(“#日期”)。面具(“99/99/9999”);
$(“(999)999-9999”);
元(锡).面具(99-999999);;
$(“#ssn”)。掩码(“999-99-9999”);
});
@LabelFor(model=>model.num\u)
@Html.TextBoxFor(model=>model.num\u tel)
验证正在进行中

但说到面具,我一无所获

他们是我得到的结果

。 . . . . . .

我找到了解决办法。
问题是我没有安装
jQuery.MaskedInput
插件

要安装
jQuery.MaskedInput
,请在Package Manager控制台中运行以下命令:

PM> Install-Package jQuery.MaskedInput -Version 1.3.1 

看看,我试过了,但它不适用于textboxfor。。。我想我遗漏了一些东西,但我不知道你在哪里得到了任何控制台错误?尝试将javascript代码放入
$(document.ready(function(){/*put here*/})
jQuery(函数($){….})
应该类似于
(函数($){…})(jQuery)。。。我不确定,但我看到了链接。