我试图制造一种习俗,即ValidationTextBox继承的Dojo Validation IdBox。 我的习俗植被将加上一个后端服务器的“合成”重复识别。
页: 1 ValidationTextBox, 并修改了两种方法:Valid()和验证()。 然而,我无法得到验证,以充分开展工作。 植被赶上,并着重指出缺少所需投入等问题。 甚至当有重复的ID(工具似乎)时,它也会赶上,但未能像预期的那样突出该领域。
我试图用下文简化的法典来孤立我的问题。 大部分是《Dojo法》的原产地,略有改动。 我的一般战略是让植被验证为一种固定的ValidationTextBox,然后测试一个重复的ID。 我修改了Valid()两种模式:便衣鉴定和验证,独一无二。 目前,独一无二的检验总是故意失败。
同样,我修改了(......)验证其正常工作,如果正常的验证成功,但独一无二的验证失败,则做一些额外的处理。 我试图反映与ValidationTextBox处于
I examined ValidationTextBox s code, but I cannot figure out how that special styling is triggered... can someone explain how ValidationTextArea works? Specifically I m not quite sure how this._maskValidSubsetError
, aria-invalid
, and this.state
are used.
(有时,我只想看到这个工具,而不要 red。) 如同在AJAX重复要求处理时显示的情况一样。
// If ValidationTextBoxValidates
isValid: function(isFocused, requireUnique) {
if (typeof requireUnique === undefined ) requireUnique = false;
var isValid = this.inherited(arguments);
var isUnique = false;
return (requireUnique ? (isValid && isUnique) : isValid);
},
validate: function(/*Boolean*/ isFocused){
// summary:
// Called by oninit, onblur, and onkeypress.
// description:
// Show missing or invalid messages if appropriate, and highlight textbox field.
// tags:
// protected
var message = "";
var isValid = this.disabled || this.isValid(isFocused);
if(isValid){ this._maskValidSubsetError = true; }
var isEmpty = this._isEmpty(this.textbox.value);
var isValidSubset = !isValid && isFocused && this._isValidSubset();
this._set("state", isValid ? "" : (((((!this._hasBeenBlurred || isFocused) && isEmpty) || isValidSubset) && this._maskValidSubsetError) ? "Incomplete" : "Error"));
this.focusNode.setAttribute("aria-invalid", isValid ? "false" : "true");
if(this.state == "Error"){
this._maskValidSubsetError = isFocused && isValidSubset; // we want the error to show up after a blur and refocus
message = this.getErrorMessage(isFocused);
}else if(this.state == "Incomplete"){
message = this.getPromptMessage(isFocused); // show the prompt whenever the value is not yet complete
this._maskValidSubsetError = !this._hasBeenBlurred || isFocused; // no Incomplete warnings while focused
}else if(isEmpty){
message = this.getPromptMessage(isFocused); // show the prompt whenever there s no error and no text
}
/// Begin custom widget code
if (isValid && !this.isValid(isFocused, true) ) {
isValid = false;
var isValidSubset = !isValid && isFocused && this._isValidSubset();
this._maskValidSubsetError = isFocused && isValidSubset; // we want the error to show up after a blur and refocus
message = ID not available ;
this.focusNode.setAttribute("aria-invalid", isValid ? "false" : "true");
}
/// End custom widget code
this.set("message", message);
return isValid;
},