AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / Desarrollar una aplicación o un sitio web / Controles, ventanas y páginas / Controles: opciones y acciones
  • 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
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Overview
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:
  1. Open the control description window.
  2. 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.
  3. 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:
  • Modificar estilo del control: 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.
  • Mostrar ícono de entrada obligatoria (ayuda): 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.
  • Mostrar texto de explicación: 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:
  1. 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.
  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, 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.
  5. Validate the control description window.
Novedad versión 2025
Note: 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.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.ValidateOnInput = ValidateDuringInput
    gMaskPhone.FormatOnInput = FormatDuringInput
    gMaskPhone.FormatOnExit = FormatDuringExit
    gMaskPhone.FormatOnEntry = FormatOnEntry
    gMaskPhone.FormatOnAssignment = 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 is string): boolean
    			RETURN MatchRegularExpression(sText , "[0-9 ]*")
    		END
    
    		INTERNAL PROCEDURE ValidateDuringExit(sText is string): boolean
    			RETURN MatchRegularExpression(sText , "[0-9 ]*")
    		END
    
    		INTERNAL PROCEDURE FormatDuringExit(sText_INOUT is string)
    			FormatStringToPhoneNumber(sText_INOUT)
    		END
    
    		INTERNAL PROCEDURE FormatOnEntry(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 handle required and invalid input programmatically:
  • Available properties:
    Novedad versión 2025
    InvalidInput
    La propiedad InvalidInput determina si se impide a los usuarios salir de un control cuando introducen datos no válidos.
    InvalidInputMessageLa propiedad InvalidInputMessage obtiene y establece el mensaje que se mostrará si el control contiene datos no válidos (máscara de entrada o valor fuera de límites).
    MandatoryInputEn MandatoryInput se utiliza para determinar si un control es obligatorio y para activar o desactivar la entrada de datos obligatoria.
    MandatoryInputMessageLa propiedad MandatoryInputMessage se utiliza para identificar y establecer el mensaje que se mostrará si el control se deja vacío (cuando la propiedad MandatoryInput está activada).
  • Available functions:
    InvalidInputDetectDetecta y señala un error en los controles con entrada obligatoria que se dejan vacíos y/o con datos no válidos.
    InvalidInputListControlCrea una lista de controles con entrada obligatoria o datos no válidos.
    InvalidInputShowMessageMuestra un error de entrada no válido para el control especificado.
Versión mínima requerida
  • Versión 26
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 15/05/2025

Señalar un error o enviar una sugerencia | Ayuda local