How to: Make an Input field required in SAPUI5.

Required fields in forms are the ones which are very necessary to proceed with form submission process. Without filling required fields data may become inconsistent or may face many other issues. Due to that reason notifying user about required fields in form is essential.

Input label required property

As in practice required field labels are shown with * symbol. That can be easily done using ‘required’ property of input label control.

Code:

Output:

Input field with Required Indicator

Label with * symbol denotes field is required. But it will not force user to enter input value. We can force user to enter value by disabling submit button until this field have some value. But to make it clear we should do inline validation for required fields. We can make use of liveChange event of Input control for that purpose as shown below.

Inline validation of required field

Code:

Output:

Success Message

 

Error Message