如何在MVC控制器中获取取消屏蔽值 [英] How to get unmask value in MVC controller
问题描述
我在我的项目中使用的是jquery.inputmask.js
I am using jquery.inputmask.js in my project as
$("#SSN").inputmask({
"mask": "999-99-9999", 'autoUnmask': true,
onUnMask: function (value) {
return value.replace('-', '');
}
});
显示时效果很好.但是当我发布此模型并读取控制器中的值时,它仍然给出999-99-9999而不是999999999.
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('-','')
保存之前.请帮忙.
谢谢!!!!
当我在jquery中读取$("#SSN").val()
时,它返回的格式为999999999,但不是controller(c#)格式.
When i read $("#SSN").val()
in jquery it is returning 999999999 format, but not in controller(c#).
推荐答案
在提交表单之前尝试执行以下操作:
Try doing this before submitting your form:
$("#SSN").inputmask('remove');
以上代码将从元素ID给出的元素中删除掩码,在本例中为"#SSN".
The above code will remove the mask from the element given with element id, in this case '#SSN'.
这篇关于如何在MVC控制器中获取取消屏蔽值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!