Login = function(){ return{ Init:function() { Ext.QuickTips.init(); Ext.form.Field.prototype.msgTarget = 'side'; var username = new Ext.form.TextField({ id:'user', fieldLabel: 'Usuario', name: 'user', defaultAutoCreate : {tag: "input", type: "text"}, anchor:'100%' }); var password = new Ext.form.TextField({ id:'pass', fieldLabel: 'Clave', name: 'pass', defaultAutoCreate : {tag: "input", type: "password"}, anchor:'100%' }); username.on("specialkey", specialKey, form); password.on("specialkey", specialKey, form); var form = new Ext.FormPanel({ labelWidth: 55, labelAlign:'right', url:'login.do', frame:true, border:false, bodyStyle:'padding:0px', defaultType: 'textfield', buttonAlign: 'right', hideBorders:true, items: [username,password], buttons: [{ text: 'Ingresar', type: 'submit', handler: function(){ Ext.MessageBox.wait('Validando usuario...', 'Por favor espere'); form.getForm().submit({ url:'login.do', method: 'POST', success:function(form, action) { if(action && action.result){ Ext.MessageBox.hide(); dialog.close(); window.location = 'index.do'; } }, failure: function(form, action) { Ext.MessageBox.hide(); Ext.MessageBox.alert('Error', 'Usuario o Clave inválida!'); } }); } }] }); function specialKey(field, e) { if (e.getKey() == e.RETURN || e.getKey() == e.ENTER ) { Ext.MessageBox.wait('Validando usuario...', 'Por favor espere'); form.getForm().submit({ url:'login.do', method: 'POST', success:function(form, action) { if(action && action.result){ Ext.MessageBox.hide(); dialog.close(); window.location = 'index.do'; } }, failure: function(form, action) { Ext.MessageBox.hide(); Ext.MessageBox.alert('Error', 'Usuario o Clave inválida!'); } }); } } var dialog = new Ext.Window({ width: 310, height: 130, modal: false, border:false, closable:false, resizable:false, draggable:false, collapsible:false, title:'Estudio Bobrovsky - Login', plain:false, items: form, renderTo: document.body }); dialog.show(); dialog.on('show', function(){ Ext.get('user').focus(); }); } }; }(); Ext.onReady(Login.Init, Login, true);