I have a lot of fields in my View
that are masked with jquery MaskedInput
. They're masked because the user need to see it with a mask, but I need to remove these masks before commiting the value in my database.
I don't want to mess up the code, since this is one of the most importants Views
in my project.
So what's the best pratice to do this?
Suppose I have this Model
:
public class MyViewModel {
public string MyMaskedProperty { get; set;}
}
And this code in View
:
@Html.TextboxFor(x=> x.MyMaskedProperty, new { @class="myMask"} )
Should I:
- Remove the mask on my
View
, using javascript, before the form is subimitted - Remove the mask on my
Model
, changing theget
ofMyMaskedProperty
to return an unmasked value - Remove the mask on my
Controller
, since it need to be unmasked only from here and beyond - Something better than the 3 solutions above.
Thanks in advance!