javascript - How to Un-Mask jquery.maskedinput Phone Number for DB Insert -


i working jquery.maskedinput.min.js in mvc web app , having hard time removing phone number mask.

js:-

@section scripts { @scripts.render("~/bundles/jqueryval") <script type="text/javascript" src="/scripts/jquery-1.8.3.min.js" charset="utf-8"></script> <script type="text/javascript" src="/scripts/jquery.maskedinput.min.js"></script> <script type="text/javascript">     $(function () {         $("#phone").mask("(999) 999-9999");     });     $(function unmaskfunc() { //this doesn't work...         $("#phone").unmask();      }); </script> } 

next have phone number field in form:

    <div class="form-group">         @html.labelfor(model => model.phoneno, htmlattributes: new { @class = "control-label col-md-2" })         <div class="col-md-10">             @html.editorfor(model => model.phoneno, new { htmlattributes = new { @class = "form-control", @id = "phone" } })             @html.validationmessagefor(model => model.phoneno, "", new { @class = "text-danger" })         </div>     </div> 

and submit button supposed call unmask function on click not work:

    <div class="form-group">         <div class="col-md-offset-2 col-md-10">             <input type="submit" value="create" class="btn btn-default" onclick="unmaskfunc()" />         </div>     </div> 

it inserts in sql db mask , want numbers. no matter place js either renders mask in textbox , inserts mask or mask won't render validation. want use unmask function min.js file!

any awesome.. still new think missing obvious. thanks!

if want convert masked output varchar in db without mask, can on server side.

if (model.phoneno != null)    model.phoneno = new string(model.phoneno.where(char.isdigit).toarray()); 

this give string numbers can inserted db.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -