commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Updated: (VALIDATOR-259) [validator] Javascript jcv_handleErrors function fails in IE when field's ancestor is not visible
Date Wed, 23 Apr 2008 03:07:21 GMT

     [ https://issues.apache.org/jira/browse/VALIDATOR-259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vasily Ivanov updated VALIDATOR-259:
------------------------------------

    Attachment: VALIDATOR-259.patch

Patch to check if browser can actually set focus on the field.

> [validator] Javascript jcv_handleErrors function fails in IE when field's ancestor is
not visible
> -------------------------------------------------------------------------------------------------
>
>                 Key: VALIDATOR-259
>                 URL: https://issues.apache.org/jira/browse/VALIDATOR-259
>             Project: Commons Validator
>          Issue Type: Bug
>          Components: JavaScript
>    Affects Versions: 1.3.1 Release
>         Environment: Win XP, Sun JVM 1.4.2_x
> Tomcat 4.1.x, Struts 1.3.8
>            Reporter: Vasily Ivanov
>         Attachments: VALIDATOR-259.patch
>
>
> 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)) {
>         focusField.focus();
>       }
>   
>       alert(messages.join('\n'));
>   }
>   function jcv_canFocus(field) {
>     var result = true;
>     
>     if (field && field != null && typeof(field) != 'undefined') {
>       if (field.disabled || field.type == 'hidden') {
>         result = false;
>       }
>       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) {
>           result = jcv_canFocus(parent);
>         }
>       }
>     } else {
>       result = false; 
>     }
>     
>     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" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message