问题
I am using jquery.inputmask.js in my project as
$("#SSN").inputmask({
"mask": "999-99-9999", 'autoUnmask': true,
onUnMask: function (value) {
return value.replace('-', '');
}
});
It works fine when displaying. But when i post this model and read the values in controller, it is still giving 999-99-9999 instead of 999999999.
I don't want to read each value and replace them as
Model.SSN.Replace('-','')
before saving. Please help.
Thanks!!!!
EDIT:
When i read $("#SSN").val()
in jquery it is returning 999999999 format, but not in controller(c#).
回答1:
Try doing this before submitting your form:
$("#SSN").inputmask('remove');
The above code will remove the mask from the element given with element id, in this case '#SSN'.
回答2:
As showed in enter link description here
You can use $().inputmask("unmaskedvalue");
Thanks
来源:https://stackoverflow.com/questions/21637938/how-to-get-unmask-value-in-mvc-controller