Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Won't Fix
-
1.3.1 Release
-
None
-
None
-
Win XP, Sun JVM 1.4.2_x
Tomcat 4.1.x, Struts 1.3.8
Description
If field is in hidden div (for example) than Javascript validation fails in IE with the following error:
"Error: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept focus."
jcv_handleErrors(messages, focusField) needs to be modified to traverse all parent nodes and check their visibility:
function jcv_handleErrors(messages, focusField) {
if (jcv_canFocus(focusField))
alert(messages.join('\n'));
}
function jcv_canFocus(field) {
var result = true;
if (field && field != null && typeof(field) != 'undefined') {
if (field.disabled || field.type == 'hidden')
if (result &&
field.style &&
field.style.visibility &&
field.style.visibility == 'hidden') { result = false; }
if (result) {
var parent = field.parentNode;
if (parent && parent != null && typeof(parent) != 'undefined' && parent.nodeType == 1)
}
} else
return result;
}
WORKAROUND:
1. Copy validateUtilities.js file from commons-validator-1.3.1.jar!\org\apache\commons\validator\javascript\validateUtilities.js into classpath under your control and apply patch above.
2. Modify validator-rules.xml:
<validator name="includeJavaScriptUtilities" classname="" method=""
methodParams="" depends="" msg=""
jsFunction="com.company.path.to.jsfile.validateUtilities" />
Attachments
Attachments
Issue Links
- relates to
-
VALIDATOR-97 [validator] Javascript mask validator fails when field is disabled
- Closed