maqskywalker
asked on
jquery masked input plugin formatting
Hi experts,
In my asp.net mvc5 , C# , razor application I'm using this jQuery masked input plugin.
http://digitalbush.com/projects/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').val('');
$('#SSNtextbox').unmask('' )
$('#SSNtextbox').attr('pla ceholder', '###-##-####');
// Social Security Number formatting
$('#SSNtextbox').mask('999 -99-9999') ;
// -------------------------- ----------
});
</script>
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:
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:
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
In my asp.net mvc5 , C# , razor application I'm using this jQuery masked input plugin.
http://digitalbush.com/projects/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').val('');
$('#SSNtextbox').unmask(''
$('#SSNtextbox').attr('pla
// Social Security Number formatting
$('#SSNtextbox').mask('999
// --------------------------
});
</script>
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:
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:
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If you notice after I click the button the formatted data is shown on my page.
https://jsfiddle.net/sz8Laaoq/
How do I only display the number I typed in on my page, without the masking?