This validation ensures that a valid value is specified for the
Date of Birth field.
Procedure
Click the
Date of Birth field.
Click the
Validations tab on the control’s
Properties view.
Click the
Add New Validation button.
The
Define Validation dialog opens.
In the
Name field type the following:
birth_date_validation
Tip: Using names for validation scripts that describe their function makes it easier for another designer to understand the form later if modifications must be made.
Click the radio button
On Value Change.
Type the following JavaScript code in the
Script text area:
var date = this.getValue();
var now = new Date();
//Validate birth date some time before today's date and
//within 120 years
if(date == null ||
(date < now && now.getFullYear() - date.getFullYear() < 120)){
true;
} else{
false;
}
Type the following text in the
Message area:
Enter a valid birth date which is a past date and in the range of last 120 years.