Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:l="sap.ui.layout" xmlns:f="sap.ui.layout.form"
- controllerName="view.login" xmlns:html="http://www.w3.org/1999/xhtml" >
- <Page title="WEBAPP">
- <content>
- <FlexBox
- alignItems="Center"
- justifyContent="Center">
- <items>
- <Image src="general/img/logo.png" width="{/widthL}"/>
- </items>
- </FlexBox>
- <FlexBox
- alignItems="Center"
- justifyContent="Center">
- <items>
- <l:Grid
- defaultSpan="L12 M12 S12"
- width="auto">
- <l:content>
- <f:Form id="loginForm"
- minWidth="1024"
- maxContainerCols="2"
- editable="true">
- <f:title>
- <core:Title text="" />
- </f:title>
- <f:layout>
- <f:ResponsiveGridLayout
- labelSpanL="3"
- labelSpanM="3"
- emptySpanL="4"
- emptySpanM="4"
- columnsL="1"
- columnsM="1" />
- </f:layout>
- <f:formContainers>
- <f:FormContainer>
- <f:formElements>
- <f:FormElement label="Username">
- <f:fields>
- <Input id="id_inputUsername" />
- </f:fields>
- </f:FormElement>
- <f:FormElement label="Password">
- <f:fields>
- <Input id="id_inputPassword" type="Password" />
- </f:fields>
- </f:FormElement>
- </f:formElements>
- </f:FormContainer>
- </f:formContainers>
- </f:Form>
- </l:content>
- </l:Grid>
- </items>
- </FlexBox>
- </content>
- <footer>
- <Bar>
- <contentRight>
- <Button id="idButtonLogin" text="Login" type="Emphasized" visible="true" press="handleFooterBarButtonPress" icon="sap-icon://accept" />
- </contentRight>
- </Bar>
- </footer>
- </Page>
- </core:View>
- <Input id="id_inputPassword"
- type="Password"
- change="onPasswordChange" />
- ...
- <Button id="idButtonLogin"
- text="Login"
- type="Emphasized"
- visible="true"
- press="handleFooterBarButtonPress"
- icon="sap-icon://accept" />
- onPasswordChange : function(oEvent) {
- this.getView().byId("idButtonLogin").firePress();
- },
- handleFooterBarButtonPress : function(oEvent) {
- jQuery.sap.require("sap.m.MessageToast");
- sap.m.MessageToast.show("Login!");
- }
- $('#id_inputPassword').on('keydown',function(e){
- e.stopPropagation();
- if (e.keyCode == 13)
- {
- $('#formLogin').submit();
- }
- });
- sap.ui.getCore().byId("inputUserName").attachBrowserEvent('keyup', function(e) {
- if (e.which == 13 || e.keyCode == 13) {
- var userName = sap.ui.getCore().byId("inputUserName").getValue();
- var password = sap.ui.getCore().byId("inputPassword").getValue();
- if (userName.length == 0) {
- sap.ui.getCore().byId('inputUserName').setValueState('Error');
- sap.ui.getCore().byId('inputUserName').focus();
- } else if (password.length == 0) {
- sap.ui.getCore().byId('inputPassword').setValueState('Error');
- sap.ui.getCore().byId('inputPassword').focus();
- } else if (userName.length > 0 && password.length > 0) {
- //YOUR LOGIC
- }
- }
- });
- //another way by using sap's default saponenter function
- sap.ui.getCore().byId("inputPassword").onsapenter = function(e) {
- var userName = sap.ui.getCore().byId("inputUserName").getValue();
- var password = sap.ui.getCore().byId("inputPassword").getValue();
- if (userName.length == 0) {
- sap.ui.getCore().byId('inputUserName').setValueState('Error');
- sap.ui.getCore().byId('inputUserName').focus();
- } else if (password.length == 0) {
- sap.ui.getCore().byId('inputPassword').setValueState('Error');
- sap.ui.getCore().byId('inputPassword').focus();
- } else if (userName.length > 0 && password.length > 0) {
- //your logic
- }
- }
- $('#idButtonLogin').bind('keydown', function(e) {
- if (e.keyCode == 13) {
- // Here you can call the function
- }
- });
Add Comment
Please, Sign In to add comment