有没有办法阻止 Dojo 在 Blur 上验证文本框?
var textbox = new ValidationTextBox({
placeholder : "search",
name : "userQuery",
required : true,
missingMessage : "Please enter search term",
onBlur : function(){
//function to stop onBlur validation
}
}, textboxNode);
最佳答案
从技术上讲,是的。但是我不确定如果它不是 onBlur,它什么时候会验证。
var textbox = new ValidationTextBox({
placeholder : "search",
name : "userQuery",
required : true,
missingMessage : "Please enter search term",
validator: function(value, constraints){
if (this.hasOwnProperty("focused")) { //true if textbox is loaded
if (!this.focused) { // if textbox not focused (onblur)
return true; // considered valid
}
}
return value !== ""; // test if value is empty
}
}, textboxNode);
关于javascript - 道场验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13016242/