Field Validation and Required Fields

Print Friendly and PDF Follow

Adding or Removing Required Fields

Field Validation and Required Fields

The Aeon web pages include some "required" form fields, such as the First Name field on the Registration form. When viewing the pages on the web, these required fields are flagged with a red asterisk. Fields that are required and not filled in by a user generate error messages. Any field can be designated "required" and fields that are currently set as required can be changed. Taking off or adding the asterisk on the web page is an important step for your users to know what they need to fill in, but it does not serve a purpose when formatting the pages and will not let Aeon know what your intentions are for the use of those fields. The required fields and their error messages are configured and must be edited in the WebValidation table.

The WebValidation Table

The WebValidation table, accessible in the Aeon Customization Manager at Web Interface | Validation, stores the fields that you require your users to populate and allows you to apply validations against any field using regular expressions.

In the 3.9 release, we modified the way web validation works to more easily allow the reuse of validation rules among multiple forms. This functionality already exists in the FormValidationOverride input, but that requires the validation rules for a given web form to be declared on the form itself. This enhancement will work similarly but will allow us to define which validation rules apply to a form in the database which will allow other parts of the system outside of form submissions to take advantage of it.

In version 3.9, the WebValidation table has been modified to no longer refer to form names. The FormName field has been renamed to RuleSet and defines the name of the set of validation rules that that row applies to. 

The WebFormValidationLinks Table

We've also added a new table named WebFormValidationLinks which describes the relationship between web forms and the validation rule sets that should be applied to submissions from that form. 

The WebFormValidationLinks table has two columns - FormName and RuleSet. For a given web form, the WebFormValidationLinks table will contain a record for each validation rule set that applies to it.

For example, two of the WebValidation records that are created on new installations are:

RuleSet
FieldName
Validation
Error
ErrorTag
AllRequests Site .+ Site is a required field.

ERRORSite

AllRequests ItemTitle .+ Title is a required field. ErrorItemTitle

and two of the WebFormValidationLinks records are:

FormName
RuleSet
DefaultRequest AllRequests
PhotoduplicationRequest AllRequests

When a user submits a default request or photoduplication request, the aeon.dll will look at the WebFormValidationLinks table to see which rule sets apply to the form (AllRequests, in this case) and then retrieves and applies the validation rules belonging to the AllRequests rule set found in WebValidation. This provides us a simple way to centralize and share validation rules among many forms. If you wanted to change the validation rule for the Site field or drop it altogether, you only have to make a single change to the WebValidation table.

Suppose we wanted to ensure that users provided a format and service level when submitting photoduplication requests. We can do this now strictly from the table editor in Customization Manager; there is no longer any need to edit the web pages. In this case, we'd add the two new validation rules to WebValidation. The rule set name can be any string up to 100 characters. For this example, we will call it PhotoduplicationRequests.

RuleSet
FieldName
Validation
Error
ErrorTag
PhotoduplicationRequests Format .+ Format is a required field. ERRORFormat
PhotoduplicationRequests ServiceLevel .+ Service level is a required field. ERRORServiceLevel

and we'd add a record to WebFormValidationLinks to link that rule set to the photoduplication request form

FormName
RuleSet
PhotoduplicationRequest PhotoduplicationRequests

Now, when a user submits a photoduplication request, both the AllRequests and PhotoduplicationRequest validations rule sets will be applied.

The default web pages have been updated to remove any FormValidationOverride inputs and the equivalent rules are now seeded into the WebValidation and WebFormValidationLinks tables.  When a site is being updated, the WebValidation.FormName field is renamed to RuleSet and the existing values are left in place. In this case, rule sets' names will be the same as their form names. Then the WebFormValidationLinks table will be populated by taking the rule sets with known Aeon form names and creating a link from that form name to its rule set. For example, before updating you have a WebValidation record with a FormName of 'ChangeUserInformation'. During the update, a record will be added to WebFormValidationLinks with the value 'ChangeUserInformation' for both the FormName and the RuleSet fields.

The FormValidationOverride input will continue to work as it previously did, except that the value attribute will now refer to the WebValidation.RuleSet field. No changes need to be made to existing web pages because of this feature.

Changing a Required Field

If you want to change a required field, its associated error message, or a validation that a field is measured against, use the WebValidation table. Aeon has many default field validations built in, and you can add as many more as you need. Some example regular expressions are listed below. When a field fails to validate against one of these regular expressions, it will return the error listed in the WebValidation table on the screen and re-display the entry screen, allowing the user to make changes as necessary.

Regular Expressions

Regular Expressions

Purpose

.+

This will make the field required, but allow any characters input into the field to pass validation.

^\d\d\/\d\d\/\d\d\d\d$

This format is for a MM/DD/YYYY date.

^\d{9}$

This is for a nine digit number.

^\d{5}(-\d{4})?$

This is for a zip code that will take 5 digits or 5 and 4 digits (nine-digit zip code).

\w+@\w+

This format is for an email address in the format Aeon@atlas-sys.com.

Default Values (Making Fields Required or Not Required)

If you want to make a field required or not required, you must edit the field value in the WebValidation table. Most fields in the WebValidation table contain the regular expression .+ meaning that any character (including Aspace) is valid in that field, but that the field requires at least one character be entered or it will return an error message. If you want to make a field not required, you can either delete the entry from the WebValidation table or change the regular expression value to .* meaning that any character would be valid and even those characters are optional. You will also need to edit the web page to remove the asterisk from the field.

Changing the Validation Value

To change a value in the Validation column to not required, click on the row you want to change to open the edit form.

Change the value to .* as explained above.

Strike your Enter or Return key to activate the Save icon.

Click the Save icon to save your changes and close the edit form.

Deleting a Required Field

If you want to eliminate an existing required field, you can delete it from the WebValidation table.

Choose the row for the field you wish to eliminate by clicking on that row.

To delete the entry click the Delete button.

You will be asked to verify that you want to delete the record. Note that this action cannot be undone.

Editing the Web Form

No matter which of the two methods you use to change a required field value, you will need to edit the web page to remove the asterisk from the field.

Open the web page containing the field you are changing and remove or hide the "required" span class for that field using the following format:

<!-- <span class="req">*</span> -->

Creating a Validation Rule for a Blank "Request For" Field Value

The Request For dropdown field on the new request web pages contains a blank field value when a researcher is listed as a proxy or associated with Activities. By default the blank field value associates the request with the researcher, however, the dropdown can be configured to validate the RequestLink fieldname against an empty value, forcing the user to select an option from the dropdown list. If a researcher does not choose a dropdown option and submits the blank value, an error message displays prompting the user to choose an option.

To create the validation rule for the blank Request For value, enter the following fields into the WebValidation table for each new request form:

RuleSet

Fieldname

Validation

Error

Error Tag

AllRequests

Site

.+

Site is a required field.

ERRORSite

AllRequests ItemTitle .+ Title is a required field. ErrorItemTitle
More Information about Regular Expressions

There are a variety of web sites available that explain techniques for creating regular expressions. Some web sites we've found helpful are:

Regular Expression Tutorial
http://www.regular-expressions.info/tutorial.html

Learning to Use Regular Expressions by Example
http://www.phpbuilder.com/columns/dario19990616.php3

The Expresso Regular Expression Tool
http://www.ultrapico.com/Expresso.htm

For further information on regular expressions, search any internet search engine for "Perl Regular Expressions".

Questions?

If this article didn’t resolve your issue, please contact Atlas Support for assistance:

Contact Support