Enabling/disabling automatic calling of validation functions (sys.AutoValidate)

sys.AutoValidate,,i1

Determines if validation performed on unchanged data

When data is entered into a textbox by means of the dialog or input command, any validation function specified for that textbox is executed when the data entry is complete. The validation function is defined by means of an optional textbox clause.

The system variable sys.AutoValidate enables or disables the automatic calling of such a validation function if the textbox has gained and lost focus without the data being changed. It may be set to OFF or ON.

If sys.AutoValidate is OFF, then the textbox validation function is called only if the data in the textbox is changed.

If sys.AutoValidate is ON, then the textbox validation function is called whenever the textbox loses focus, whether or not the data it contains has changed. The exception to this occurs when the user exits from the textbox with the BACKSPACE key during the input command. In this cases the field is reset to the value it had when the user moved into the field.

If a mouse is being used, clicking in another textbox is an attempt to leave the current textbox, regardless of their relative positions on the screen. The validation function is always called if sys.AutoValidate is ON, and is also called if the data in the textbox has changed and sys.AutoValidate is OFF.

If the validation function returns an error, focus is returned to the textbox for the user to re-enter the data.

By default, sys.AutoValidate is OFF.

Note

The lose focus event may be used to emulate the effects of sys.AutoValidate.


EXAMPLE

In this example the ValidatePrice function is called after the user has pressed RETURN to exit the input field, whether or not the contents of pr.price have changed.

     +textbox PriceBox at 5,4 {
          field = pr.price
          validate = ValidatePrice
     }
     ...

     sys.AutoValidate = ON
     input PriceBox
     ...

!function ValidatePrice() {
     if pr.price = 0 then error "Price must be entered"
     return
}

RELATED TOPICS

Textbox events and functions