Problem
I created a webpage for users to register for a conference. In the form the users can select different seminars in the conference as the following:
Section A | Section B | Section C |
|---|---|---|
| Seminar 1: 9 am - 12 pm | Seminar 2: 9 am - 12 pm | Seminar 3: 9 am - 12 pm |
| Seminar 3: 1 pm - 5 pm | Seminar 4: 1 pm - 5 pm | Seminar 5: 1 pm - 5 pm |
| Seminar 6: 6 pm - 9 pm | Seminar 7: 6 pm - 9 pm | Seminar 8: 6 pm - 9 pm |
Several seminars will be held at the same time. The server should reject the input if the selection leads to a schedule conflict.
Solution
I have experimented with several ways for this type of erroring checking. Before I tell you what can work, let me tell you what cannot work. Using IsEmpty function may not work properly. For example, you can set up a validation rule for the field Seminar 1 as "IsEmpty(Seminar 2) and IsEmpty(Seminar 3)" It works fine as long as the user does not go back to edit his record. If the user wants to cancel Seminar 2 and choose Seminar 1, he will not be allowed to do so because even if Seminar 2 is deselected, the field value is "blank" rather than "empty." ("Blank" is datum of nothing but "empty" is no datum at all) Also, in a web form even if the field is empty, it will be submitted as "blank."
The following is a better way:
- Create fields "Seminar 1-Seminar 9" as numeric fields.
- In Auto Enter make "0" as the default value.
- Create three text fields. Name them as "Check morning," "Check afternoon" and "Check evening."
- In "Check morning, enter this validation rule:
"Seminar 1 + Seminar 2 + Seminar 3 < 2". It means that the user can choose either none or one of those seminars. Apply the same rule into "Check afternoon" and "Check evening." - In both new.htm and record_detail.htm, add the following tags. It will force the submission to activiate the validation.
<input type=hidden name="Check morning" value=1> <input type=hidden name="Check afternoon" value=1> <input type=hidden name="Check evening" value=1>
The same approach can be applied to more complicated scheduling.
