Adding Validation for Time of Accident Field

This validation ensures that a valid value is specified for the Time of Accident field.

Procedure

  1. Click the Time of Accident field.
  2. Click the Validations tab on the control’s Properties view.
  3. Click the Add New Validation button.

    The Define Validation dialog opens.

  4. In the Name field type the following:
    accident_time_validation
  5. Click the radio button On Value Change.
  6. Type the following JavaScript code in the Script text area:
    //Accident time must not be in the future
    var accTime = this.getValue();
    var now = new Date();
    if(now < accTime){
      false;
    } else{
      true;
      }
  7. Edit the text in the Message area to the following:
    Accident time must not be in the future.
  8. Click Finish.