Skip to Content

sap ui5 input field, combobox and sap.m.table validation

Hi Experts,

If I have to put required validation in case of simple form has many input fields, combobox and sap.m.table should have at least single row validation. The validation error should come either in the footer or in the field itself. Please suggest what is the best way to achieve this or any help url.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Mar 15 at 11:07 AM

    Hi

    You can call a function at submit button (event) - as below which I am using. If that validation fails i make the field as Red - and set error flag as E -

    You can see the code to set the value state as Error if fails.

    May be this is a simple way - but you can look for help - using message popover - in some elegant way

    validateFormData : function(oEntry) {
    
    	var lv_msg = "";
    	//alert(oEntry.Name1);
    	this.getView().byId("englishName").setValueState(sap.ui.core.ValueState.Information);
    		if ((oEntry.Name1 === "")) {
    				sap.m.MessageToast.show("Please enter mandatory fields");
    							lv_msg = "E";
    		this.getView().byId("englishName").setValueState(sap.ui.core.ValueState.Error);
    						}
    		if ((oEntry.Name2 === "")) {
    			sap.m.MessageToast.show("Please enter mandatory fields");
    						lv_msg = "E";
    			this.getView().byId("arabicName").setValueState(sap.ui.core.ValueState.Error);
    						}
                              
    		if ((oEntry.Longitude === "")) {
    				sap.m.MessageToast.show("Please enter mandatory fields");
    					lv_msg = "E";
    			this.getView().byId("longitude").setValueState(sap.ui.core.ValueState.Error);
    						}						
    
    
    		if ((oEntry.Latitude === "")) {
    			sap.m.MessageToast.show("Please enter mandatory fields");
    				lv_msg = "E";
    			this.getView().byId("latitude").setValueState(sap.ui.core.ValueState.Error);
    						}							
    			return lv_msg;
    },
    
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 15 at 07:57 PM

    I suggest to use the message manager: https://ui5.sap.com/#/entity/sap.ui.core.message.MessageManager


    Another one that can help a lot in combination with constraints , old but gold by Robin Van Het Hof : https://blogs.sap.com/2015/11/01/generic-sapui5-form-validator/


    kr, Wouter

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.