简体   繁体   中英

jQuery mask input without changing value

I am using masked-input-plugin but it changes value and field becomes invalid ...

in my js

$phoneInput.mask('99-99-99-999');

and later in browser console

('.phone-input-order-form').val()
"99-99-99-999"

Is there any way to get from val "999999999" while it masked ?

I am thinking to extend jQuery val but maybe you know better way? maybe without this plugin? :D

Overriding jQuery's val() function might cause unexpected issues with other scripts. Maybe try something like this:

$.fn.maskVal = function () {
    return $(this).mask();
};

Demo: http://jsfiddle.net/alan0xd7/w4s0v7y3/

$('.phone-input-order-form').mask(); => "999999999"

做点什么

yourstring.replace("-", ""); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM