Commons Validator
  1. Commons Validator
  2. VALIDATOR-25

[validator] maxlength on textarea in firefox the javascript doesn't match serverside

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      Description

      When using firefox with a textarea that has a maxlength, if you include carriage
      returns in your data entry, the client side javascript will not match the server
      side java. On the client side the javascript is only seeing a \n for the
      carriage returns while on the server side the java is seeing a \n\r. So if you
      have a max length of 5, 1\n2\n3 will pass the client side, put fail the server
      side since there is will be 1\n\r2\n\r3.

        Activity

        Alan Olmanson created issue -
        Hide
        Niall Pemberton added a comment -

        I have modified both the server side and client side validation so that
        the "line ending" length can be specified for the min and max length
        validators. The validators now "adjust" the value's length if a line ending
        length is specified.

        http://svn.apache.org/viewcvs?rev=367226&view=rev

        So for example, to treat line endings (either "\n" or "\n\r") as a length of 1

        <field property="foo" depends="required,minlength,maxlength">
        <var>
        <var-name>lineEndLength</var-name>
        <var-value>1</var-value>
        </var>
        <var>
        <var-name>minlength</var-name>
        <var-value>5</var-value>
        </var>
        <var>
        <var-name>maxlength</var-name>
        <var-value>20</var-value>
        </var>
        </field>

        This will be available in the next nightly build:

        http://cvs.apache.org/builds/jakarta-commons/nightly/commons-validator/

        However, if your using this with Struts the Struts FieldChecks class needs to
        be modified for the server side validation in Struts to work with this change.
        Struts will be changed once the next release of Commons Validator has been
        done. I have opened I have modified both the server side and client side validation so that
        the "line ending" length can be specified for the min and max length
        validators. The validators now "adjust" the value's length if a line ending
        length is specified.

        http://svn.apache.org/viewcvs?rev=367226&view=rev

        So for example, to treat line endings (either "\n" or "\n\r") as a length of 1

        <field property="foo" depends="required,minlength,maxlength">
        <var>
        <var-name>lineEndLength</var-name>
        <var-value>1</var-value>
        </var>
        <var>
        <var-name>minlength</var-name>
        <var-value>5</var-value>
        </var>
        <var>
        <var-name>maxlength</var-name>
        <var-value>20</var-value>
        </var>
        </field>

        This will be available in the next nightly build:

        http://cvs.apache.org/builds/jakarta-commons/nightly/commons-validator/

        However, if your using this with Struts the Struts FieldChecks class needs to
        be modified for the server side validation in Struts to work with this change.
        Struts will be changed once the next release of Commons Validator has been
        done. I have opened Bug 38191 against Struts in order that it doesn't get
        forgotten.

        Closing this as FIXED against Struts in order that it doesn't get
        forgotten.

        Closing this as FIXED

        Show
        Niall Pemberton added a comment - I have modified both the server side and client side validation so that the "line ending" length can be specified for the min and max length validators. The validators now "adjust" the value's length if a line ending length is specified. http://svn.apache.org/viewcvs?rev=367226&view=rev So for example, to treat line endings (either "\n" or "\n\r") as a length of 1 <field property="foo" depends="required,minlength,maxlength"> <var> <var-name>lineEndLength</var-name> <var-value>1</var-value> </var> <var> <var-name>minlength</var-name> <var-value>5</var-value> </var> <var> <var-name>maxlength</var-name> <var-value>20</var-value> </var> </field> This will be available in the next nightly build: http://cvs.apache.org/builds/jakarta-commons/nightly/commons-validator/ However, if your using this with Struts the Struts FieldChecks class needs to be modified for the server side validation in Struts to work with this change. Struts will be changed once the next release of Commons Validator has been done. I have opened I have modified both the server side and client side validation so that the "line ending" length can be specified for the min and max length validators. The validators now "adjust" the value's length if a line ending length is specified. http://svn.apache.org/viewcvs?rev=367226&view=rev So for example, to treat line endings (either "\n" or "\n\r") as a length of 1 <field property="foo" depends="required,minlength,maxlength"> <var> <var-name>lineEndLength</var-name> <var-value>1</var-value> </var> <var> <var-name>minlength</var-name> <var-value>5</var-value> </var> <var> <var-name>maxlength</var-name> <var-value>20</var-value> </var> </field> This will be available in the next nightly build: http://cvs.apache.org/builds/jakarta-commons/nightly/commons-validator/ However, if your using this with Struts the Struts FieldChecks class needs to be modified for the server side validation in Struts to work with this change. Struts will be changed once the next release of Commons Validator has been done. I have opened Bug 38191 against Struts in order that it doesn't get forgotten. Closing this as FIXED against Struts in order that it doesn't get forgotten. Closing this as FIXED
        Henri Yandell made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 37962 12342805
        Henri Yandell made changes -
        Affects Version/s 1.4 Final [ 12311663 ]
        Key COM-2653 VALIDATOR-25
        Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
        Component/s Validator [ 12311135 ]
        Project Commons [ 12310458 ] Commons Validator [ 12310494 ]
        Henri Yandell made changes -
        Affects Version/s 1.4 Final [ 12311841 ]
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Alan Olmanson
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development