3

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#).

user1882705
  • 1,081
  • 4
  • 15
  • 43

2 Answers2

0

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'.

halfpastfour.am
  • 5,764
  • 3
  • 44
  • 61
hhk
  • 508
  • 7
  • 15
  • Care to elaborate? – halfpastfour.am May 02 '17 at 12:30
  • @BobKruithof it is just needed to be added above code to onclick of the submit button. .inputmask('remove') will remove related mask from the element given with element id which is "#SSN" in this case. – hhk May 02 '17 at 13:00
-1

As showed in enter link description here

You can use $().inputmask("unmaskedvalue"); Thanks

Rai Vu
  • 1,595
  • 1
  • 20
  • 30
JWSantos
  • 1
  • 1
  • While this link may answer the question, it is better to include most essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. Also elaborate the answer..Please check [answer] – Morse Jul 11 '18 at 02:32