Uploaded image for project: 'Commons Validator'
  1. Commons Validator
  2. VALIDATOR-97

[validator] Javascript mask validator fails when field is disabled

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0 (alpha)
    • None
    • None
    • None
    • Operating System: other
      Platform: All

    • 21043

    Description

      This applies to Struts 1.1 RC2 - no RC2 in bugzilla

      Hi, After adding the mask validator to an html:text field, the validator failed
      with the following javascript error when the field has been disabled.

      "Line 1610
      char: 20
      Error: Can't move focus to the control because it is invisible, not enalbed,
      or of a type that does not accept foucs.
      Code: 0
      URL: http://localhost:8800/cds/createSchedulePage3Controller.do"

      It would appear that the validator is trying to validate the field and then set
      focus to it even though it has been disabled. Unless it is a requred field, I
      would not want it validated as the user would not have completed its value.

      The line of code being referred to is below:

      function validateMask(form) {
      ...
      if (fields.length > 0)

      { 1610>> focusField.focus(); alert(fields.join('\n')); }

      return isValid;
      }

      I had a play with the javascript in validation-rules.xml and adding the
      following line seems to correct the problem:

      function validateMask(form) {
      ...
      var field = form[oMasked[x][0]];

      if ((field.type == 'text' ||
      field.type == 'textarea') &&
      (field.value.length > 0) &&
      >>> (field.disabled == false)) {

      if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
      ...

      Would this be applicable to all JS validation routines, except
      perhaps 'required'. I know that I would want it on most of the routines.

      Thanks, Colin

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              colin@froggatt.com Colin Froggatt
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: