jquery屏蔽输入插件,以便在出错时不清除字段 [英] jquery masked input plugin to not clear field when errored
问题描述
我在看 http://digitalbush.com/projects/masked-input -plugin /
我这样称呼它:
$(control).mask('999-999-9999');
如果出现问题,我不希望它丢弃用户输入,例如:他们还没有完成
And I don't want it to throw away the users input if something is wrong, e.g. they haven't finished
[407-555-____]
如果你输入这么多后离开现场,它会清除它。我想留下它以便以后完成。
If you leave the field after having typed this much, it clears it. I'd like to leave it so they can finish later.
我是jQuery的新手,我查看了他的来源,但我找不到任何方式做到这一点,我也找不到任何方法来编辑它来完成我想要的,因为代码对我来说是神秘的。
I'm new to jQuery, and I've looked through his source, but I can't find any way to do that, nor can I find any way to edit it to accomplish what I want, because the code is arcane to my eyes.
推荐答案
看起来我应该让整个面具可选:
It looks like I should just make the whole mask optional:
mask('?999-999-9999')
这样控件认为用户拥有的是有效,我可以继续。即使它不是面具的可选部分。
That way the control thinks what the user has is "valid" and I can continue. Even though it isn't really the optional part of the mask.
这篇关于jquery屏蔽输入插件,以便在出错时不清除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!