除了去除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