ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / Developing an application or website / Controls, windows and pages / Controls: Options and actions
  • Overview
  • Control characteristics: required input
  • Blocking required input
  • Non-blocking required input
  • Texts and display options: required input settings
  • Control characteristics: invalid input
  • Setting up the invalid input check
  • Texts and display options: invalid input settings
  • Example
  • Managing required and invalid input programmatically
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
WINDEV and WINDEV Mobile include several options to manage required or invalid input, both via the window editor and by programming.
These options are available for the following controls:
  • Edit control,
  • Combo Box control (standard or editable),
  • Check Box and Radio Button controls,
  • Rating control.
You can indicate required data input:
  • Via the hint text (if the control is empty),
  • By changing the control style,
  • By showing the required input icon,
  • By showing the explanation text.
Control characteristics: required input
WINDEV and WINDEV Mobile include two ways of managing required data input:
  • blocking required input,
  • non-blocking required input.

Blocking required input

Blocking required input prevents the user from leaving required controls.
To configure a control with blocking required input:
  1. Open the control description window.
  2. In the "Details" tab, in "Required / invalid input":
    • Check "Required input".
    • Select "Prevent from leaving control".
    Remark: the options for indicating the required input can be configured via the "Texts and display options" button..
  3. Validate the control description window.

Non-blocking required input

The non-blocking required input makes it possible to check if the different required controls have been left empty at the end. This means that the user is not blocked while entering data.
To configure a control with non-blocking required input:
  1. Open the control description window.
  2. In the "Details" tab, in "Required / invalid input":
    • Check "Required input".
    • Select "Use InvalidInputDetect".
    Remark: the options for indicating the required input can be configured via the "Texts and display options" button..
  3. Validate the control description window.
  4. In the validation code of the window (e.g. button used to add data to a database), use InvalidInputDetect. This function is used to check whether all required input controls in the current window have been filled in. Depending on the options set in "Texts and display options", the controls that do not match the requirements are highlighted.
Remark: The optional event "Allow closing" can also be used to validate the different elements of a window and to call InvalidInputDetect. If this event returns False, the current window will not be closed.

Texts and display options: required input settings

The "Texts and display options" button in the "Details" tab of the control description allows you to define changes in the appearance of the control.
Two display modes are available:
  • showing an indication: indicates that the input control is required if it is empty BEFORE InvalidInputDetect is executed.
  • showing an error: indicates that the input control is required if it is empty AFTER InvalidInputDetect is executed.
In both cases, you have various options:
  • Modify control style: This option changes the style of the control. The style used for the indication and for the error can be set in the "Style" tab of the control.
  • Display required input icon: This option displays a specific icon in the control. The icon used and its position relative to the input area are set in the "Style" tab of the control ("Required input (indication/error): Explanation & icon", "Icon" button.
    If this option is selected, you can enter the explanation text. This text will be displayed when hovering over the control and when the icon is clicked. Remark: If the explanation text is not specified, a default explanation text will be displayed.
  • Display explanation text: Displays the explanation text below the control. If the explanation text is not specified, a default explanation text will be displayed. Caution: This option modifies the interface. If this option is selected, the selected hint text is displayed directly below the control in the window being edited. It may be necessary to adapt the interface so that the control is displayed in its entirety.
Control characteristics: invalid input
WINDEV and WINDEV Mobile allow you to check if the input corresponds to a mask defined with a variable of type InputMask. If it does not, the input is considered invalid when InvalidInputDetect is called.

Setting up the invalid input check

To set up the invalid input check in a control:
  1. Define a variable of type InputMask that corresponds to the input mask to be applied to the control.
    Caution: Don't forget to define the WLanguage procedure called by the CheckIfValidInput property of the InputMask variable. This procedure will be automatically called when the InvalidInputDetect function is used to determine if the text entered is valid.
  2. Define the input mask to be used via the InputMask property in the code of the control.
  3. Open the control description window.
  4. In the "Details" tab, in "Required / invalid input":
    • Select "Use InvalidInputDetect".
    • Configure the options for indicating the required input via the "Texts and display options" button.
  5. Validate the control description window.
  6. In the validation code of the window (e.g. button used to add data to a database), use InvalidInputDetect. This function checks for invalid and required input errors.

Texts and display options: invalid input settings

The "Texts and display options" button in the "Details" tab of the control description allows you to define changes in the appearance of the control.
If the input is invalid, you have various options:
  • Modify control style: Modifies the control style. The style used for the different elements of the invalid input can be defined in the "Style" tab of the control.
  • Display required input icon: Displays a specific icon in the control. The icon used and its position relative to the input area are set in the "Style" tab of the control ("Invalid input: Explanation & icon", "Icon" button.
    If this option is selected, you can enter the explanation text. This text will be displayed when hovering over the control and when the icon is clicked. Remark: If the explanation text is not specified, a default explanation text will be displayed.
  • Display explanation text: Displays the explanation text below the control. If the explanation text is not specified, a default explanation text will be displayed. Caution: This option modifies the interface. If this option is selected, the selected hint text is displayed directly below the control in the window being edited. It may be necessary to adapt the interface so that the control is displayed in its entirety.

Example

This example includes an Edit control (used to enter a phone number) and a verification button.
  • The "Exit" event contains the following code:
    MySelf.InputMask = gMaskPhone
  • The initialization code of the project contains the following code, which define the InputMask variable:
    gsMaskPhone is string = "99 99 99 99 99"
    gMaskPhone is InputMask
     
    gMaskPhone.CheckIfValidInput = CheckIfValidInput
    gMaskPhone.ValidateDuringInput = ValidateDuringInput
    gMaskPhone.FormatDuringInput = FormatDuringInput
    gMaskPhone.FormatDuringExit = FormatDuringExit
    gMaskPhone.FormatDuringEntry = FormatDuringEntry
    gMaskPhone.FormatDuringAssignment = FormatDuringAssignment
     
    INTERNAL PROCEDURE CheckIfValidInput(sText is string): boolean
    RETURN MatchRegularExpression(sText , "[0-9 ]*") _AND_
    Length(StringFormat(sText, ccIgnoreInsideSpace)) = 10
    END
     
    INTERNAL PROCEDURE FormatDuringInput(LOCAL sTextBefore is string,
    LOCAL nCursorBefore is int,
    LOCAL nEndCursorBefore is int, sTextAfter is string,
    nCursorAfter is int,
    nEndCursorAfter is int)
    IF Length(sTextBefore) > Length(sTextAfter) THEN RESULT
    //No action if deleting
    // if at the end
    IF nEndCursorAfter = Length(sTextAfter) +1 THEN
    // include " " if needed at this location
    IF Middle(gsMaskPhone, nEndCursorAfter, 1) = " " THEN
    sTextAfter += " "
    nEndCursorAfter ++
    nCursorAfter = nEndCursorAfter
    END
    END
    END
     
    INTERNAL PROCEDURE ValidateDuringInput(sText string): boolean
    RETURN MatchRegularExpression(sText , "[0-9 ]*")
    END
     
    INTERNAL PROCEDURE ValidateDuringExit(sText string): boolean
    RETURN MatchRegularExpression(sText , "[0-9 ]*")
    END
     
    INTERNAL PROCEDURE FormatDuringExit(sText_INOUT is string)
    FormatStringToPhoneNumber(sText_INOUT)
    END
     
    INTERNAL PROCEDURE FormatDuringEntry(sText_INOUT is string)
    FormatStringToPhoneNumber(sText_INOUT)
    END
    INTERNAL PROCEDURE FormatDuringAssignment(sText_INOUT is string)
    FormatStringToPhoneNumber(sText_INOUT)
    END
     
    INTERNAL PROCEDURE FormatStringToPhoneNumber(sText_INOUT is string)
    sOut is string = ""
    sText_INOUT = StringFormat(sText_INOUT, ccIgnoreInsideSpace + ccIgnoreSpace)
    let nText = 1
    FOR n = 1 _TO_ Length(gsMaskPhone)
    IF nText > Length(sText_INOUT) THEN BREAK
    IF gsMaskPhone [n] = " " THEN
    sOut += " "
    ELSE
    sOut += sText_INOUT[nText]
    nText ++
    END
    END
    sText_INOUT = sOut
    END
  • The verification button contains the following code:
    InvalidInputDetect()
Managing required and invalid input programmatically
WINDEV and WINDEV Mobile include different properties and functions to manage required and invalid input through programming:
  • Available properties:
    InvalidInputMessageThe InvalidInputMessage property gets and sets the message that will be displayed if the control contains invalid data (input mask or value out of bounds).
    InvalidInputPreventExitThe InvalidInputPreventExit property is used to determine if it is possible to leave the control in case of invalid input.
    MandatoryInputThe MandatoryInput property is used to determine if a control is required and to enable or disable the required data input.
    MandatoryInputMessageThe MandatoryInputMessage property is used to identify and set the message that will be displayed if the control is left empty (when the MandatoryInput property is enabled).
  • Available functions:
    InvalidInputDetectDetects and signals an error on required controls left empty and/or controls with invalid data.
    InvalidInputListControlBuilds a list of controls that require data input/contain invalid data.
    InvalidInputShowMessageDisplays an invalid input error for the specified control.
Minimum version required
  • Version 26
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 06/19/2023

Send a report | Local help