Ext.onReady(function(){ Ext.QuickTips.init(); // turn on validation errors beside the field globally Ext.form.Field.prototype.msgTarget = 'side'; var bd = Ext.getBody(); var application = new Ext.FormPanel({ labelAlign: 'side', buttonAlign: 'right', id: 'application', bodyBorder:false, border:false, frame:false, hideBorders:true, bodyStyle: '', monitorValid:true, fileUpload: true, width: 400, labelWidth: 125, items: [{ layout:'column', items:[{ columnWidth:1, layout: 'form', items: [ { xtype: 'textfield', value: 'DAR72131927', hidden: true, labelSeparator: '', name: 'jobid' },{ xtype: 'textfield', value: 'DAR72131927', hidden: true, labelSeparator: '', name: 'reference' },{ xtype: 'textfield', hidden: true, labelSeparator: '', name: 'jobtitle', id: 'ed_jobtitle' },{ xtype: 'textfield', hidden: true, labelSeparator: '', name: 'consultant_name', id: 'ed_consultant' },{ xtype:'fieldset', title: 'Contact Information', autoHeight:true, defaultType: 'textfield', items :[new Ext.form.ComboBox( { store: ['Mr', 'Mrs.', 'Miss', 'Ms.', 'Dr.', 'Prof.'], fieldLabel: 'Title', typeAhead: true, forceSelection: true, triggerAction: 'all', emptyText:'Select a title...', selectOnFocus:true, id: 'ed_title', name: 'salutation', width: 100 }), { fieldLabel: 'First Name', name: 'firstname', allowBlank:false, id: 'ed_firstname', blankText: 'First name cannot be blank', anchor:'95%' }, { fieldLabel: 'Last Name', name: 'lastname', allowBlank:false, blankText: 'Last name cannot be blank', id: 'ed_lastname', anchor:'95%' } ] }, { xtype:'fieldset', title: 'Address', autoHeight:true, defaultType: 'textfield', items :[{ xtype:'textfield', fieldLabel: 'Address', name: 'address1', anchor:'95%', id: 'ed_address1' }, { xtype:'textfield', name: 'address2', labelSeparator: '', anchor:'95%', id: 'ed_address2' }, { xtype:'textfield', name: 'address3', labelSeparator: '', anchor:'95%', id: 'ed_address3' }, { xtype:'textfield', fieldLabel: 'Suburb', name: 'suburb', anchor:'95%', id: 'ed_suburb' }, { xtype:'textfield', fieldLabel: 'Post Code', name: 'postcode', anchor:'95%', id: 'ed_postcode' }, { xtype:'textfield', fieldLabel: 'State', name: 'state', anchor:'95%', id: 'ed_state' }, new Ext.form.ComboBox({ store: countries, fieldLabel: 'Country', displayField:'country', typeAhead: true, mode: 'local', forceSelection: true, triggerAction: 'all', emptyText:'Select a country...', selectOnFocus:true, id: 'ed_country', name: 'country', editable: true, width: 230 }) ] }, { xtype:'fieldset', title: 'Contact Method', autoHeight:true, defaultType: 'textfield', items :[{ fieldLabel: 'Phone', name: 'phone', allowBlank:false, blankText: 'Phone number cannot be blank', id: 'ed_phonenum', anchor:'95%' }, { fieldLabel: 'Mobile', name: 'mobile', id: 'ed_mobilenum', anchor:'95%' }, { fieldLabel: 'Email', name: 'email', vtype: 'email', allowBlank:false, blankText: 'Email cannot be blank', id: 'ed_email', anchor:'95%' } ] }, { xtype:'fieldset', title: 'Other', autoHeight:true, defaultType: 'textfield', items :[{ fieldLabel: 'Min Remuneration', name: 'min-renum', anchor:'95%' }, { xtype: 'textarea', fieldLabel: 'Cover Note', name: 'covernote', anchor:'95%' }, { xtype: 'fileuploadfield', id: 'form-file', emptyText: 'Select cv location...', fieldLabel: 'Upload CV', allowBlank:false, blankText: 'Please attach a CV', name: 'cv', anchor:'95%' } ] } ] }] }], bbar: new Ext.StatusBar({ id: 'form-statusbar', defaultText: 'Ready', plugins: new Ext.ux.ValidationStatus({form:'application'}) }), buttons: [{ text: 'Submit Application', formBind : true, handler: function() { application.getForm().submit({ clientValidation: true, url: '/send_application.php?email=danr@skyerecruitment.com', success: function(form, action) { //Ext.Msg.alert("Application Sent", action.result.msg); //history.go(-1); document.location = '/jobdetails/DAR72131927/applied'; }, failure: function(form, action) { switch (action.failureType) { case Ext.form.Action.CLIENT_INVALID: Ext.Msg.alert("Failure", "Form fields may not be submitted with invalid values"); break; case Ext.form.Action.CONNECT_FAILURE: Ext.Msg.alert("Failure", "Ajax communication failed"); break; case Ext.form.Action.SERVER_INVALID: Ext.Msg.alert("Failure", action.result.msg); } } }); } } /* ,{ text: 'Cancel', handler: function() { history.go(-1); } } */] }); application.render('apply_for_job'); application.form.isValid(); });