How to get unmask value in MVC controller

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 great on display. But when I submit this model and read the values ​​in the controller, it still gives 999-99-9999 instead of 999999999.

I do not want to read each value and replace it as

Model.SSN.Replace('-','')  

before saving. Please, help.

Thank!!!!

EDIT:

When I read $("#SSN").val()in jquery, it returns the format 999999999, but not in the controller (C #).

+3
source share
2 answers

Try this before submitting the form:

$("#SSN").inputmask('remove');

The above code will remove the mask from the element specified with the element identifier, in this case "#SSN".

0
source

easily with the mask plugin you can use

$( '# ') cleanVal();.

-2

All Articles