NetTalk Central

Author Topic: How does validation work?  (Read 4083 times)

ChrisLaurie

  • Newbie
  • *
  • Posts: 40
    • View Profile
How does validation work?
« on: June 20, 2007, 12:44:17 PM »
Hi All

I'm trying to figure out how to do validation in a form. I have a date field that the user enters. In the validate routine I take the date and find the appropriate defined period based on the entered dates and the start end dates of the period. If I find the appropriate period I update another field and all is ok. If I do NOT find a valid period, I change the comment to 'Date not in valid period. I also set loc:Invalid. The error comment display works but even though I set loc:Invalid the form still accepts the invalid date.

If I copy the validate code to validate record then the form will not take the date BUT the comment is not updated. I also expected the field to be colored?

So, what is best practise for doing field validations where the validations are more complex than simple range, alpha etc.

Cheers

Chris

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11158
    • View Profile
Re: How does validation work?
« Reply #1 on: June 20, 2007, 10:56:07 PM »
Hi Chris,

There are 2 distinct times when validation can occur.

1) as the field is entered

2) as the form is completed.

I think you're mixing the two up a bit.
Loc:Invalid is only used in the latter

However it's correct to say that fields must be validated when the form is completed - and they _may_ be validated when the user enters them.

I'd need to see an example to determine why the erroroneous field was not colored correctly.

Cheers
Bruce