<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
<script src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-libs="sap.m" data-sap-ui-resourceroots='{"view": "./"}' data-sap-ui-theme="sap_bluecrystal" data-sap-ui-xx-bindingSyntax="complex">
</script>
<script>
sap.ui.localResources("view");
var app = new sap.m.App({
initialPage: "idMain"
});
var page = sap.ui.view({
id: "idMain",
viewName: "view.Main",
type: sap.ui.core.mvc.ViewType.XML
});
app.addPage(page);
app.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
sap.ui.controller("view.Main", {
onPress: function (evt) {
jQuery.sap.require("sap.m.MessageToast");
sap.m.MessageToast.show(evt.getSource().getId() + " Pressed");
},
validate : function()
{
var value1 = this.byId("Input1").getValue();
var value2 = this.byId("Input2").getValue();
var value3 = this.byId("Input3").getValue();
if( value1 )
{
this.byId("Input2").setEnabled(false);
this.byId("Input3").setEnabled(false);
this.byId("Input2").setValueState( sap.ui.core.ValueState.None );
this.byId("Input3").setValueState( sap.ui.core.ValueState.None );
}
else
{
this.byId("Input2").setEnabled(true);
this.byId("Input3").setEnabled(true);
}
if( value2 && value3 )
{
this.byId("Input1").setEnabled(false);
this.byId("Input2").setValueState( sap.ui.core.ValueState.None );
this.byId("Input3").setValueState( sap.ui.core.ValueState.None );
}
if( !value2 && !value3 )
{
this.byId("Input1").setEnabled(true);
this.byId("Input2").setValueState( sap.ui.core.ValueState.None );
this.byId("Input3").setValueState( sap.ui.core.ValueState.None );
}
if( value2 && !value3 )
{
this.byId("Input1").setEnabled(false);
this.byId("Input2").setValueState( sap.ui.core.ValueState.None );
this.byId("Input3").setValueState( sap.ui.core.ValueState.Error );
}
if( !value2 && value3 )
{
this.byId("Input1").setEnabled(false);
this.byId("Input2").setValueState( sap.ui.core.ValueState.Error );
this.byId("Input3").setValueState( sap.ui.core.ValueState.None );
}
}
});
<mvc:View
height="100%"
controllerName="view.Main"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Page
title="Page"
class="marginBoxContent" >
<Label text="Product 1" />
<Input
valueLiveUpdate="true"
liveChange="validate"
id="Input1"
class="sapUiSmallMarginBottom"
type="Text"
placeholder="Enter Product 1..."
enabled="true"
editable="true"
/>
<Label text="Product 2" />
<Input valueLiveUpdate="true"
liveChange="validate"
id="Input2"
class="sapUiSmallMarginBottom"
type="Text"
placeholder="Enter Product 2..."
enabled="true"
editable="true"
/>
<Label text="Product 3" />
<Input valueLiveUpdate="true"
liveChange="validate"
id="Input3"
class="sapUiSmallMarginBottom"
type="Text"
placeholder="Enter Product 3..."
enabled="true"
editable="true"
/>
<footer>
<Toolbar>
<ToolbarSpacer/>
<Button type="Emphasized" text="validate" press="onPress" />
</Toolbar>
</footer>
</Page>
</mvc:View>