Menu

#24 Date Validation

open
nobody
None
5
2005-11-17
2005-11-17
sphawkins
No

I have setup the following date validation on a field
on my form:

<field property="LETTER_SENT" depends="date">
<msg name="date" key="Invalid date entered "
resource="false"/>
<var>
<var-name>datePatternStrict</var-name>
<var-value>dd-MMM-yyyy</var-value>
</var>
</field>

When I use one of the navigation buttons (next, last
etc) the field is validated correctly but if I use the
Update or Insert buttons valid dates are reported as
invalid?

Also is there anyway of validating that a date is on or
before the date of entry.

Steven

Discussion

  • Henner Kollmann

    Henner Kollmann - 2005-11-17

    Logged In: YES
    user_id=569597

    1. I have to test this. Unchanged fields should'nt be validated.
    Which version do you use? Do you use javascript
    validation or server side validation?

    2. Not with the validation classes yet. You can extend the
    DbFormsValidator class to do this.....

    Henner

     
  • sphawkins

    sphawkins - 2005-11-18

    Logged In: YES
    user_id=1344693

    I am using 2.6 Snapshot_20051105 and javascript validation.
    I have just tried it with server side validation and it
    works ok.

    To clarify, the problem is when I amend a date and click on
    Update or Insert valid dates are shown as invalid. Once the
    amended date has been accepted by clicking Next, I can go
    back to the record and click on Update without a problem.

    Steven

     
  • sphawkins

    sphawkins - 2005-11-18

    Logged In: YES
    user_id=1344693

    I just realised that it was using the date validation in the
    validator-rules file that I copied from the bookstore
    example. If I remove this file the date validation works as
    expected.

    Sorry for wasting your time.

    This would seam to suggest that the amended validators in
    the validator-rules file are only used when Update or Insert
    are clicked and not for the navigation buttons. Is this correct?

    Steven.

     
  • Henner Kollmann

    Henner Kollmann - 2005-11-18

    Logged In: YES
    user_id=569597

    Validation should happen if you have

    (autoUpdate = true or Insert/Update a record)
    AND
    (value is changed.

    If you remove the validator-rules file no validation will
    happen.

    And validation should work in the bookstore example too.

    So it's time for a little test session. Hope that i have
    some free time at the weekend.

    Henner

     
  • Henner Kollmann

    Henner Kollmann - 2005-11-20

    Logged In: YES
    user_id=569597

    OK, i just tried it with the bookstore example and
    everything works as i expected:

    - Unchanged fields are not reported as an error even if the
    data format is'nt correct.
    - Changed fields are reported as an error in update/insert.

    But there is another problem:
    MMM is not recognized as a month pattern during
    javascript validation. Month pattern must match MM to be
    recognized!

    Maybe that's the problem?

    Regards,
    Henner

     
  • sphawkins

    sphawkins - 2005-11-30

    Logged In: YES
    user_id=1344693

    I'm currently using the following validation with
    javascriptValidation="true" and the validation-rules from
    the bookstore example and it appears to be validating dates
    correctly using the MMM format.

    <field property="LETTER_SENT" depends="date">
    <msg name="date"
    key="Invalid date entered (format dd-Mon-yyyy) "
    resource="false"/>
    <var>
    <var-name>datePattern</var-name>
    <var-value>dd-MMM-yyyy</var-value>
    </var>
    </field>

    I think you right that the original problem was that when
    using datePatternStrict a month pattern of MMM is not
    recognized in the javascript valiadtion.

    Incidentally if I use datePatternStrict validation errors
    are shown in a alert window but when using datePattern they
    are shown on the form. Does this mean that validation using
    datePattern is done server side?

    Thanks
    Steven

     
  • Henner Kollmann

    Henner Kollmann - 2005-11-30

    Logged In: YES
    user_id=569597

    Yes i think so. Normally serverside validation errors are
    directly written on the page, javascript validation
    generates alert messages.

     

Log in to post a comment.

MongoDB Logo MongoDB