You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2005/11/29 04:26:26 UTC

DO NOT REPLY [Bug 37681] New: - validator *.js focusField.focus() error when the field is hidden filed

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37681>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37681

           Summary: validator *.js  focusField.focus() error when the field
                    is hidden filed
           Product: Struts
           Version: 1.2.8
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Validator Framework
        AssignedTo: dev@struts.apache.org
        ReportedBy: shendong70@163.com


In commons-validator\org\apache\commons\validator\javascript\*.js all validator 
javascript use following method to set focus when the field varification get 
error. 
1. define variable to keep the field: var focusField = null;
2. check if it is the first error field, if yes, save the field to focusField, 
else skip it.
 if (i == 0) {
   focusField = field;
 }
3. set focus:
if (fields.length > 0) {
          focusField.focus();
          alert(fields.join('\n'));
}

The problem will happen when the filed is hidden filed, then the line 
focusField.focus();
will get javascript error. So I feel the best and easy way is change focusField 
as arrary, doing the field check through for loop to get the first field which 
is not hidden filed.
like this:
1)       var focusField = new Array();

2)
focusField[i++] = field;
fields[i] = oDate[x][1];

3)
for (x in focusField) {	
  if(focusField[x].type != 'hidden'){
      focusField[x].focus();
      break;
  }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org