|
|
|
|
|
- Overview
- Controls with required input
- Implementing required input
- Non-blocking required input
- Required input settings: Text and display options
- Controls with invalid input
- Checking for invalid input
- Handling invalid input in non-blocking mode
- Invalid input settings: Text and display options
- Example
- Managing required and invalid input programmatically
Required or invalid input in WINDEV
WINDEV and WINDEV Mobile include several options to manage required or invalid input, both in the window editor and programmatically. 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.
Controls with required input In a WINDEV or WINDEV Mobile application, you can indicate whether input is required or not in an Edit control. If input is required, there are two possible cases: - required input can be blocking.
In this case, the input is checked when users leave the Edit control. If the user has not made an entry in the field, they will be blocked and will not be able to leave the field. - required input can be non-blocking.
In this case, the input is checked once all the fields have been filled out. This means users are not prevented from leaving a control. Controls with required input must be checked programmatically, with InvalidInputDetect.
Implementing required input To configure a control with required input: - Open the control description window.
- Go to the "Details" tab and select a value for "Required input":
- "No" (default): The control will not highlight required input.
- "Yes, blocking": The control will highlight required input in blocking mode. Users will not be able to leave the control without entering data.
- "Yes, non-blocking": The control will highlight required input in non-blocking mode. Users may leave the control blank. The verification will be performed by the InvalidInputDetect function.
Note: You can configure the required input highlighting options by clicking the button. - Validate the control description window.
Note: The MandatoryInput property is used to get and set the value of this option. Non-blocking required input To handle required input in non-blocking mode, use InvalidInputDetect (for example, in the code of a button used to add elements to a database). This function is used to check whether all required input controls in the current window have been filled in. Depending on the options set via the  button, the controls that do not match the requirements are highlighted. Note: The optional "Allow closing" event 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. Required input settings: Text and display options The  button next to the "Required input" option allows you to define the visual changes of the control.
Two display modes are available: - Indication: Highlights the control if the input is empty BEFORE InvalidInputDetect is executed.
- Error: Highlights the control if the input 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 (hint): 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. Note: 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.
Controls with 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.
Invalid input can be: - blocking.
In this case, the mask is checked when users leave the control. If the mask does not match the expected input mask, users will not be able to leave the control. - non-blocking.
In this case, the mask is checked once all the fields have been filled out. This means users are not prevented from leaving a control. Controls with invalid input must be checked programmatically, with InvalidInputDetect.
Checking for invalid input To check for invalid input in a control: - Define a variable of type InputMask that corresponds to the input mask to be applied to the control.
Note: 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. - Define the input mask to be used via the InputMask property in the code of the control.
- Open the control description window.
- In the "Details" tab, select a value for "Invalid input":
- "No" (default): The control will not highlight invalid input.
- "Yes, blocking": The control will highlight invalid input in blocking mode. Users will not be able to leave the control without entering valid data.
- "Yes, non-blocking": The control will highlight invalid input in non-blocking mode. Users will be able to enter invalid data in the control. The verification will be performed by the InvalidInputDetect function.
Note: You can configure the required input highlighting options by clicking the button. - Validate the control description window.
New in version 2025Note: The InvalidInput property is used to get and set the value of this option. Handling invalid input in non-blocking mode To handle invalid input in non-blocking mode, use InvalidInputDetect (for example, in the code of a button used to add elements to a database). This function checks for invalid input in all Edit controls for which the "invalid" option is enabled in the current window. Depending on the options set via the  button, the controls that do not match the requirements are highlighted. Note: The optional "Allow closing" event 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. Invalid input settings: Text and display options The  button next to the "Invalid input" option allows you to define the visual changes of the control.
If the input is invalid, you have various options: - Modify control style: This option changes the style of the control. 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: 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 ("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. Note: If the explanation text is not specified, a default explanation text will be displayed.
- Display explanation text: This option 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.MasqueSaisie = gMasqueTéléphone
- The initialization code of the project contains the following code, which define the InputMask variable:
gsMasqueTéléphone is string = "99 99 99 99 99"
gMasqueTéléphone is InputMask
gMasqueTéléphone.CheckIfValidInput = VerifieSiSaisieValide
gMasqueTéléphone.ValidateOnInput = ValideEnSaisie
gMasqueTéléphone.FormatOnInput = FormateEnSaisie
gMasqueTéléphone.FormatOnExit = FormateEnSortie
gMasqueTéléphone.FormatOnEntry = FormateEnEntrée
gMasqueTéléphone.FormatOnAssignment = FormateEnAffectation
INTERNAL PROCEDURE VerifieSiSaisieValide(sTexte is string) : boolean
RETURN MatchRegularExpression(sTexte, "[0-9 ]*") _AND_
Length(StringFormat(sTexte, ccIgnoreInsideSpace)) = 10
END
INTERNAL PROCEDURE FormateEnSaisie(LOCAL sTexteAvant is string,
LOCAL nCurseurAvant is int,
LOCAL nFinCurseurAvant is int, sTexteApres is string,
nCurseurApres is int,
nFinCurseurApres is int)
IF Length(sTexteAvant) > Length(sTexteApres) THEN RETURN
IF nFinCurseurApres = Length(sTexteApres) + 1 THEN
IF Middle(gsMasqueTéléphone, nFinCurseurApres, 1) = " " THEN
sTexteApres += " "
nFinCurseurApres ++
nCurseurApres = nFinCurseurApres
END
END
END
INTERNAL PROCEDURE ValideEnSaisie(sTexte is string) : boolean
RETURN MatchRegularExpression(sTexte, "[0-9 ]*")
END
INTERNAL PROCEDURE ValideEnSortie(sTexte is string) : boolean
RETURN MatchRegularExpression(sTexte, "[0-9 ]*")
END
INTERNAL PROCEDURE FormateEnSortie(sTexte_INOUT is string)
FormateChaîneEnNuméroTéléphone(sTexte_INOUT)
END
INTERNAL PROCEDURE FormateEnEntrée(sTexte_INOUT is string)
FormateChaîneEnNuméroTéléphone(sTexte_INOUT)
END
INTERNAL PROCEDURE FormateEnAffectation(sTexte_INOUT is string)
FormateChaîneEnNuméroTéléphone(sTexte_INOUT)
END
INTERNAL PROCEDURE FormateChaîneEnNuméroTéléphone(sTexte_INOUT is string)
sOut is string = ""
sTexte_INOUT = StringFormat(sTexte_INOUT, ccIgnoreInsideSpace + ccIgnoreSpace)
let nTexte = 1
FOR n = 1 _TO_ Length(gsMasqueTéléphone)
IF nTexte > Length(sTexte_INOUT) THEN BREAK
IF gsMasqueTéléphone[n] = " " THEN
sOut += " "
ELSE
sOut += sTexte_INOUT[nTexte]
nTexte ++
END
END
sTexte_INOUT = sOut
END
- The verification button contains the following code:
Managing required and invalid input programmatically WINDEV and WINDEV Mobile include different properties and functions to handle required and invalid input programmatically: - Available properties:
| | | The InvalidInput property determines if a control prevents the user from leaving when they enter invalid data. | InvalidInputMessage | The InvalidInputMessage property gets and sets the message that will be displayed if the control contains invalid data (input mask or value out of bounds). | MandatoryInput | The MandatoryInput property is used to determine if a control is required and to enable or disable the required data input. | MandatoryInputMessage | The 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:
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|