2

有没有办法阻止 Dojo 验证文本框 onBlur?

var textbox = new ValidationTextBox({
     placeholder : "search",
     name : "userQuery",
     required : true,
     missingMessage : "Please enter search term",
     onBlur : function(){
          //function to stop onBlur validation
     }
}, textboxNode);
4

1 回答 1

1

从技术上讲,是的。但我不确定它何时会验证它是否不是 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);
于 2012-10-22T21:14:23.760 回答