Set inputfield as required
Function: Set inputfield as required
This action allows you to control whether a specific input field on your form must be filled out by users. You can make a field mandatory (required) or optional, and even customize the message displayed if a required field is left empty.
Input
- UI element: This is the specific input field on your form that you want to modify. For example, a text box for an email address, a number field for quantity, or a date picker.
- Type: UI element
- Required: Choose whether this input field should be mandatory for users to fill out (
True
) or optional (False
).- Type: True/False
- Required message: This is the custom message that will appear next to the input field if a user tries to submit the form without filling out this required field. If left blank, a default message will be used.
- Type: A piece of text
Output
The selected input field on your form will have its 'required' status and associated message updated according to your settings. This change will be immediately reflected in the user interface.
Execution Flow
Real-Life Examples
Here are some practical ways you can use the "Set inputfield as required" action in your applications:
-
Example 1: Make an email field mandatory for user registration.
- Inputs:
- UI element:
Email Address Input Field
(e.g., a field namedemailInput
on your registration form) - Required:
True
- Required message:
Please enter your email address to register.
- UI element:
- Result: The 'Email Address Input Field' on the registration form will now be mandatory. If a user tries to submit the form without entering an email, they will see the message "Please enter your email address to register."
- Inputs:
-
Example 2: Make a "Company Name" field optional for individual users.
- Inputs:
- UI element:
Company Name Input Field
(e.g., a field namedcompanyName
on a user profile form) - Required:
False
- Required message:
\(Optional for individuals\)
- UI element:
- Result: The 'Company Name Input Field' on the user profile form will no longer be mandatory. Users can choose to leave it empty without any error messages, and the hint "(Optional for individuals)" might appear.
- Inputs:
-
Example 3: Dynamically change a "Shipping Address" field to be required only if "Delivery" is selected.
- Inputs:
- UI element:
Shipping Address Input Field
(e.g., a field namedshippingAddress
) - Required:
True
(This value would be set conditionally, for instance, after a user selects "Delivery" from a dropdown menu) - Required message:
Shipping address is required for delivery orders.
- UI element:
- Result: When a user selects "Delivery" as their preferred method, the 'Shipping Address Input Field' will become mandatory. If they try to proceed without entering an address, they will see the message "Shipping address is required for delivery orders." If they later change their selection to "Pickup," you could use this action again to set
Required
toFalse
for the same field.
- Inputs: