Validating Data Input

Validation rules can be applied to most controls on a form. If you hover over the control with the mouse, press F11 and you can then set specific rules on the control.

The control types that this works on
  • Text control
  • Memo control
  • Numeric control
  • Combo/Select control
  • Calendar control
  • Checkbox control

It does NOT work on grids or buttons. It does work on the control types above if they appear in a rowEditTemplate/pop up.

Sorts of operation you can perform
  • Make the current control (i.e. the control you are hovering over) mandatory with a red box
  • Add a validation rule (i.e. in the grid at the bottom of the F11 screen). this allows you to compare the current controls with a target control and:
    • Condition - this rule allows you to state that the current control equals a certain value (e.g. the current control must equal 1, or must be greater than 50, etc.  For a combo control, you must put in the value as it appears in the control, eg. NA-Not Recorded, which may include both the Code and Description).
    • DateCompareControls, TextCompareControl. NumericCompareControl - this rule allows you to compare the current control value with a target control (e.g. the current control must equal the target control, or must be greater than, etc). The target control is a list of controls on the current open form.
    • TextRegularExpression - this rule allows you to add a regular expression to the current control
    • MandatoryIfCompareWithControlEmpty, NotMandatoryIfCompareWithControlNotEmpty, MandatoryIfCompareControlSpecificValue - these rules allow you to make the current control mandatory and compare it with a target control. So if the target control is empty the current control is mandatory - for instance. 
    • EmptyIfCompareControlSpecificValue - this rule specifies that the current control must be empty if another control has a specific value
    • DateNotInFuture. Added in v3.1, this validation rule disallows dates which are in the future being entered. Select the Condition Type option DateNotInFuture. Once you have closed and reopened the form, the rule will have been applied.

 

Use of Regular Expressions

The use of TextRegularExpression is powerful as you can force data to be entered in a certain way. For example, on the Ownership or Parcel form, in the UK customisation, there is a field to enter a C/P/H number (County/Parish/Holding) number. This is always in a standard format with 2 digits for the County, 3 for the Parish and 4 for the holding all separated by a forward slash. The following rule will achieve this and if text if entered in any other format, it will not be accepted. 

Another useful regular expression is where you want to limit text to a particular length of text in a particular field. Usage of this might be where you are synchronising data between another system e.g. financial database and that database has field length restrictions. In this case, the regular expression would be:

^(?=.{1,60}$).*

This is restricting the character string to 60 characters. ^{1,60}$ would not be sufficient as this would not handle white spaces between words. 

For advice on how to use regular expressions, the following is a list of good web sites that either have RegEx tutorials or sandboxed environments that enable you to try out various regular expressions.

1. http://regexone.com extremely good for beginners
2. http://www.regular-expressions.info/tutorial.html
3. http://www.rexegg.com/
4. http://www.weitz.de/regex-coach/ (includes access to a free Windows tool)

A useful free tool is called Expresso (http://www.ultrapico.com/expresso.htm) though the Regulator is also highly recommended (http://sourceforge.net/projects/regulator/)

Find out more