How to get unmask value in MVC controller

笑着哭i 提交于 2019-12-06 06:27:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!