Reputation: 275
I want to mask a phone number using html helpers (TextBoxFor)
there is my code
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; }
View :
<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>
the validation is working
but when it comes to mask i get nothing
their is the result i get
. . . . . . .
Upvotes: 2
Views: 5593
Reputation: 275
I found a solution.
The problem was that I have not installed jQuery.MaskedInput
plugin.
To install jQuery.MaskedInput
, run the following command in the Package Manager Console:
PM> Install-Package jQuery.MaskedInput -Version 1.3.1
Upvotes: 2