jquery masked input plugin formatting

Hi experts,
In my asp.net mvc5 , C# , razor application I'm using this jQuery masked input plugin.


So on my view inside the jquery document ready section my code looks like this:

    <script type="text/javascript">
        $(document).ready(function () {
        // ------------------------------------

                    $('#SSNtextbox').attr('placeholder', '###-##-####');
                    //  Social Security Number formatting

        // ------------------------------------

So on my page i have a text box that looks like this

 @Html.TextBoxFor(model => model.EmployeeSSN, new { id = "SSNtextbox", @class = "SSNText", @placeholder = "" })

The masking works just fine on my textbox.

When I run my page the place holder in my textbox looks like this which is what I want:

on load
So then when i click in the text box and start typing the masking works just fine and looks like this:

This textbox is part of a form.

When I click the submit button though I noticed that this textbox is passing the social i entered along with the masking. In visual studio debugging the data that shows that its passing looks like this:

the data that my textbox is passing
Anyone know how to pass only the numbers I typed in (without the masking)?

So instead of passing this, like it's doing now:   123-45-6789

The value my form should submit should be only this: 123456789
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

maqskywalkerAuthor Commented:
Here is a fiddle of my example:

If you notice after I click the button the formatted data is shown on my page.


How do I only display the number I typed in on my page, without the masking?
David S.Commented:
I strongly recommend removing the extra characters on the server.

However, if you have to do it before then, it looks like you can just call mask() to get only the numerals. Using your form's submit event, you can go through your masked fields and do this:
$('#SSNtextbox').val( $('#SSNtextbox').mask() );

Open in new window

Source: https://github.com/digitalBush/jquery.maskedinput/issues/58

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.