In this topic you will learn how to create the form that allows adding new conference information into the database. The insert operation will be handled with the Insert Record Form Wizard. However, not any kind of data will be allowed into the database. Information that is submitted must obey several rules:
The start date must be in the future.
The end date must be greater than the start date entered by the user.
If no conference center has been specified, the address will not be required. If a conference center is entered, the address will become mandatory.
To build this page, you must first build the basic insert form, with no special validation options. These will be configured afterwards.
The insert form will be created using the Insert Record Form Wizard from ImpAKT:
Open the add page in Dreamweaver.
Go to the Insert bar > MX Kollection tab and click on the Insert Record Form Wizard button (the first on the left edge). The user interface that loads is divided into three steps. Configure them as shown below:
In the first step define database related information, and what page to load after the insert completes:
In the Connection drop-down menu select the database connection created earlier.
In the Insert into table drop-down menu select the conferences_con table.
The table's Primary key column will be automatically detected and displayed in the drop-down menu.
In the After inserting, go to enter the page to load after the insert operation completes. Either type in, or click the Browse button to select the index page in the site root.
When all fields have been configured, click
Next to move on.

In the second step define the fields to use in the transaction. You can set the fields properties by selecting each one of them and using the controls below the Form fields grid:
For the start_date_con field change the Label to Starts on.
For the end_date_con field change the Label to Ends on.
For the building_con change the Label to Conference center.
For the address_con,
in the Display as drop-down menu select the
Text area option. This will give users more
room to write into.

The third step of the wizard allows you to define validation rules for each field. You do not have to change any rule at this point, as it will be done later on.
Click Finish to exit the wizard and apply the changes.
All form elements have been added to the page by the wizard. The insert
form is fully functional, missing only the validation elements explained
on top of this page. This is how the page should look in browser

In this section of the tutorial you will learn how to enforce date rules: the start date will be set to be in the future, and the end date will be set to be further into the future than the start date. This is accomplished for the form added with the Insert Record Form Wizard by editing the Validate Form server behavior that is automatically added.
This is how the server behavior tab should look like after having added
the insert form above:

To define the validation rules for dates, follow the steps below:
Double-click the Validate Form server behavior to edit it.
The interface displays all the recognized form fields in a grid, with their names and properties. You can change the settings for any of them by selecting it in the grid and changing values in the controls below. For this part, you are only interested in defining rules for the start and end date.
First the start date. It must be in the future, which can translate to it being greater than today. To define this rule:
Select the start_date_con field in the grid.
In the Validation format
drop-down menu select Date.
Note: If you want to compare against date and
time, select Datetime in the menu.
Some new fields have become visible. The format
used is displayed (you can change that from the Control
Panel), and two text boxes: Greater than
and Less than. In the Greater
than field enter {NOW}. This is a mark-up
that will get replaced at run-time with the current date.
Note: If using Date and time validation, enter {NOW_DT}
for the mark-up.
Next, the end date. The condition for this field is that it must be greater than the start date.
Select the end_date_con field in the grid.
From the Validation
format drop-down menu select Date.
Note: You must select the same format as for the start_date_con.
Therefore, if you used Datetime
for the start date, this is what you have to select here as well.
In the Greater than field that appears you must enter the value to compare with. You will be using another InterAKT mark-up which will retrieve the value of the start_date_con field: {start_date_con}. This is simply the name of the field in the insert transaction enclosed by curly braces.
Check the Custom message option. In the text box that is enabled, enter a message to be displayed: The conference must end after it begins.
This is all that is needed to set up date validation
rules. The configured user interface should look like the following:

Click OK to close the interface and apply the changes.
Now test the page. Save it and preview it in browser. If you try entering an incorrect end date, the entered error message will be displayed:

The next step is to make the address field required only when a conference center has been specified.
Requiring a field when another has a value also requires the use of the Validate Form server behavior, which will start conditioned by the fact that the other field has a value. Because the rest of the validation rules have to get executed independent from this condition you will add another Validate Form server behavior which will work only on the address field:
Go to the Server Behavior tab > Plus (+) > MX Kollection > Form Validation and apply the Validate Form server behavior.
By default, all fields are marked as not required
and without any validation - you can see it in the grid. To make the address
field required, select it in the grid, and then check the Required
checkbox below the grid:

Also check the Custom message option, and in the Error message text field enter Please specify the address of the convention center.
Next you have to configure the form validation to execute only when a conference center has been specified (in the building_con field). To do so, click on the Advanced tab. This is where you can define a condition to start the execution. You can either type the condition directly, or, better yet, use the Condition Builder.
In the Advanced tab click the Build Condition button. This will open a new user interface with three fields: the two expressions and the operator. The two text boxes for expressions have the InterAKT dynamic data icon. Configure this user interface as follows:
Click on the InterAKT
Dynamic Data icon next to the first expression field. From the
user interface that loads select in the Transaction
field drop-down menu the building_con
field.

Click OK to define the first expression.
Back in the Condition
Builder select the not equal sign (!=) for the Condition,
and leave the Expression 2 field empty. This
condition can be read as: execute if building_con
is not empty.

Click OK to close the user interface and add the condition to the Validate Form server behavior.
Back in the Validate Form
user interface, the condition you built has been entered into the text
box:

You can now click OK to apply the server behavior to the page.
Save the page and load it in a browser. To test it, enter correct dates
(you've already configured it above) and only the conference center name,
with no address. An error message will be displayed:

The application is now complete. It will only allow adding conferences that start and end appropriately, and will require an address whenever a conference center is specified.