A client action to restrict characters with Regular Expression (RegEx) that allows users to set specific constraints on the characters that can be entered in a certain field, and it works for both web and mobile applications (input has to be of text type). It uses pattern-matching syntax to validate the input and ensure that it meets the specified criteria. For example, if the user wants to restrict a field to only accept alphanumeric characters, they can set a RegEx pattern to match only letters and numbers. This feature can be used to enforce data quality and consistency, ensuring that the entered data meets the required format and is free of unwanted characters. By implementing this client action, developers can improve the user experience and prevent errors in data input for both web and mobile platforms.
Steps to use the client action:
1. Create a handler for the On Change event of the input field (input has to be of text type).
2. Call the client action and pass the input widget Id, the desired regular expression pattern for allowed characters and boolean values to convert to upper or lower case as parameters.
3. Assign the output of the action to the same variable bound to the input field.
Note: If you are going to use ConvertToUpper or ConvertToLower, please use both upper and lower case charater set, for example 'a-zA-Z', otherwise the converted values might be removed based on allowed pattern.Note: If both ConvertToUpper and ConvertToLower are set to True then ConvertToUpper will be used.Note: It is recommended to clearly define the desired regular expression pattern for allowed characters to ensure the correct behavior of the client action. Use a website such as https://regex101.com/ to generate the pattern.
Note: Change the data type of the output in the 3rd step using Outsystems built-in actions as required to match the data type of the variable bound to the input field.