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

[validator] validator-rules.xml JavaScript fails when field not present in jsp

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.3.0 Release
    • None
    • None
    • Operating System: All
      Platform: All

    • 14471

    Description

      Sometimes, esp. when writing a wizard-like interface, not all the form fields
      will be present in a single jsp - each jsp asks for a subset of the required
      data from the user. It's useful to validate each piece of data. If you use the
      validator.xml as supplied, it will fail for rules where the particular field
      doesn't exist in the jsp.

      I propose adding a check in each of the validators to check if the form field
      is undefined (i.e. doesn't exist) before attempting to use its properties.

      Each validator must have the following line or similar (in the case
      of "required") under the for (x in oRequired) { line:

      for (x in oRequired) {
      if (form[oRequired[x][0]] != undefined) {

      Hope this is of use!

      Andrew

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--validator-rules.xml
          35 kB
          Andrew Berridge
        2. ASF.LICENSE.NOT.GRANTED--validator-rules.xml
          42 kB
          Rob Hannah
        3. ASF.LICENSE.NOT.GRANTED--javascript.zip
          13 kB
          Paul Benedict

        Activity

          People

            niallp Niall Pemberton
            andrew_berridge@sandwich.pfizer.com Andrew Berridge
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: