Ext.onReady( function() { doSubmit = function() { if(login.getForm().isValid()) { login.getForm().submit({ method:'POST', params: {language:'2'} , waitTitle:'Conectando', waitMsg:'Enviando Datos', success: function(form, action){ obj = Ext.util.JSON.decode(action.response.responseText); window.location = obj.url; }, failure: function(form, action){ if(action.failureType == Ext.form.Action.SERVER_INVALID) { obj = Ext.util.JSON.decode(action.response.responseText); Ext.MessageBox.show({ title: 'login_info', msg: obj.errors.reason, buttons: Ext.MessageBox.OK, animEl: 'buttonLogin', icon: Ext.Msg.WARNING, fn : function(){ if (obj.errors.cambio!=""){ window.location = "cambio_clave.asp?opcion="+obj.errors.cambio; } } }); } else { Ext.MessageBox.show({ title: 'Atención', msg: 'Error. Pongase en contacto con la asistencia técnica', buttons: Ext.MessageBox.OK, animEl: 'buttonLogin', icon: Ext.Msg.ERROR }); } login.getForm().reset(); } }); } } var login = new Ext.FormPanel({ width:320, height:170, labelWidth:80, url:'validar.asp', frame:true, title:'Escriba su usuario y contraseña', defaultType:'textfield', monitorValid:true, keys: [{ key: Ext.EventObject.ENTER, fn: doSubmit }], items:[{ xtype:'panel', width:220, items:[{ xtype:'label', text:'Sistema preparado para funcionar con el navegador Internet Explorer con vista de compatibilidad habilitada' }] }, { fieldLabel:'Usuario', name:'username', allowBlank:false, maxLength:8 }, { fieldLabel:'Contraseña', name:'password', inputType:'password', allowBlank:false, maxLength:8, maxLengthText:'longitud_maxima {0}' } ], buttons: [{ id: 'buttonLogin', text:'Entrar', formBind: true, type: 'submit', handler:function(){ doSubmit(); } }] }); var botones = new Ext.Panel({ // width:300, layout:'fit', buttons:[{ // xtype:'button', id: 'buttonForget', text:'Olvidé mi contraseña', handler: function(){ window.location = "cambio_clave.asp?opcion=4"; } },{ // xtype:'button', id: 'buttonMod', text:'Modificar la contraseña', handler: function(){ window.location = "cambio_clave.asp?opcion=3"; } }] }); createBox = function(t, s){ return ['
', '
', '

', t, '

', s, '
', '
', '
'].join('');}; msg=function(){ var msgCt; msgCt = Ext.DomHelper.append(document.body, {id:'msg-div'}, true); msgCt.alignTo(document, 't-t'); var m = Ext.DomHelper.append(msgCt, {html:createBox("Atención", "")}, true); m.slideIn('t').pause(2).ghost("t", {remove:true}); }; var win = new Ext.Window({ layout:'column', width:300, height:230, style: { marginTop: '1px', cellsPadding:'0px', cellsPaccing: '0px' }, closable: false, resizable: false, // plain: false, items: [login, botones] }); var xwin = 500; var ywin = 200 ; win.setPosition(xwin, ywin); win.show(); });