除了去除checkVal(在input.val(“”)),你也可以改变调用clearBuffer 。在原始代码中是:clearBuffer(0,len);删除所有用户输入。如果您将此更改为clearBuffer(lastMatch + 1,len),则返回 ;将显示用户输入,然后显示仍需完成正确输入的掩码占位符。
我还在.bind中添加了一条用户消息。这适用于我们,因为我们正在使用MaskedInput来处理一种类型的输入。我正在检查任何输入比位置7更进一步,因为这是用户输入启动的地方。
这里是我做过什么:
.bind("blur.mask", function() {
// find out at which position the checkVal took place
var pos = checkVal();
// if there was no input, ignore
if (pos <=7) {input.val(""); clearBuffer(0, len);}
// if the user started to input something, which is not complete, issue an alert
if (pos > 7 && pos < partialPosition) alert("Tell the user what he needs to do.");
if (input.val() != focusText)
input.change();
})
检查了这一点它可以帮助http://jsfiddle.net/elclanrs/eanS5/ – elclanrs 2012-03-20 21:27:35
@elclanrs我不明白如何,涉及到我对蒙面输入插件的问题。你的代码不会做任何掩码? – McKay 2012-03-20 21:29:55
哦,误解了这个问题。我以为你想让用户在模糊的时候发出警报,但是看起来你想做相反的权利? – elclanrs 2012-03-20 21:31:12