Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何让 jQuery 在带有掩码的字段中接受错误的值。
对于下面的代码:
$("#element").mask("999.999.999-99");
如果我将值 444.444.44 放在该字段上,则焦点将被清除。
有没有办法不改变这个值?
我找到了答案!
只需添加“?” 面具前:
$('#element').mask('?999.999.999-99');
解决此问题的最佳方法是使用 autoclear 选项:
$("#element").mask("999.999.999-99", {autoclear: false});