I have four text fields with labels name, age, city and phone number.I have to validate it if it left empty. it should alert me to fill. How to validate a text field with required field validator in sapui5?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- jQuery add and remove delay
Even using the required property will not help as UI5 does not puts any controls in forms tags. The required property sets an attribute
You can use jQuery to select all the aria-required elements and process them on any other controls event say press of button.
Below is sample code for the same.
You can simply write a function that get the textfields and checks their value.
This could look like this:
Then you can bind the function on the button-click, for example when creating the button:
Additionally the
TextField
has an attribute calledvalueState
.In connection with its event
liveChange
there is the opportunity to validate the input while typing:(https://openui5.hana.ondemand.com/docs/api/symbols/sap.ui.core.ValueState.html)
You can validate it on change of the field value itself as below
Or you can write a function for validation on click of some button.