Ext.onReady(function(){ Ext.QuickTips.init(); // Create a variable to hold our EXT Form Panel. // Assign various config options as seen. var login = new Ext.FormPanel({ id:'win_formCL', frame:true, labelWidth:80, url:'modulo.php?mod=start&sm=msLogin', frame:true, title:'Por favor, Identifíquese...', defaultType:'textfield', monitorValid:true, // Specific attributes for the text fields for username / password. // The "name" attribute defines the name of variables sent to the server. items:[{ fieldLabel:'Usuario', name:'loginUsername', allowBlank:false },{ id:'loginPassword', fieldLabel:'Clave', name:'loginPassword', inputType:'password', allowBlank:false, enableKeyEvents : true } ,{ id:'loginCode', fieldLabel:'Código', name:'loginCode', inputType:'password', allowBlank:true, enableKeyEvents : true } ], // All the magic happens after the user clicks the button buttons:[{ text:'Login', formBind: true, // Function that fires when user clicks the button handler:function() { fLogin(); } }] }); Ext.getCmp('loginPassword').on('keydown', function(field, e) { var k = e.getKey(); if(k == e.ENTER) { fLogin(); } }); Ext.getCmp('loginCode').on('keydown', function(field, e) { var k = e.getKey(); if(k == e.ENTER) { fLogin(); } }); function fLogin() { var clField = login.getForm().findField('loginPassword'); var clStr = clField.getValue(); clField.setValue(md5(md5(clStr+'r0c8u2sd')+'232459')); login.getForm().submit({ method:'POST', waitTitle:'Conectando', waitMsg:'Enviando información...', success:function(){ /* Ext.Msg.alert('Estado', 'Identificación correcta!', function(btn, text) { if (btn == 'ok') { var redirect = ''; window.location = redirect; } }); */ var redirect = ''; window.location = redirect; }, // Failure function, see comment above re: success and failure. // You can see here, if login fails, it throws a messagebox // at the user telling him / her as much. failure:function(form, action){ if(action.failureType == 'server'){ obj = Ext.util.JSON.decode(action.response.responseText); Ext.Msg.alert('Identificación incorrecta!', obj.errors.reason); }else{ Ext.Msg.alert('Atención!', 'Servidor no encontrado : ' + action.response.responseText); } login.getForm().reset(); } }); } // This just creates a window to wrap the login form. // The login object is passed to the items collection. var win = new Ext.Window({ layout:'fit', width:300, height:160, closable: false, resizable: false, plain: true, border: false, items: [login] }); win.show(); });