ContactForm.js
上传用户:dawnssy
上传日期:2022-08-06
资源大小:9345k
文件大小:3k
源码类别:

JavaScript

开发平台:

JavaScript

  1. /*!  * Ext JS Library 3.1.0  * Copyright(c) 2006-2009 Ext JS, LLC  * licensing@extjs.com  * http://www.extjs.com/license  */ Ext.ns('Ext.app');
  2. Ext.app.ContactForm = Ext.extend(Ext.FormPanel, {
  3.     formTitle: 'Contact Information (English)',
  4.     firstName: 'First Name',
  5.     lastName: 'Surname',
  6.     surnamePrefix: 'Surname Prefix',
  7.     company: 'Company',
  8.     state: 'State',
  9.     stateEmptyText: 'Choose a state...',
  10.     email: 'E-mail',
  11.     birth: 'Date of Birth',
  12.     save: 'Save',
  13.     cancel: 'Cancel',
  14.     
  15.     initComponent : function(config) {
  16.         Ext.apply(this, {
  17.             labelWidth: 100, // label settings here cascade unless overridden
  18.             url:'save-form.php',
  19.             frame:true,
  20.             title: this.formTitle,
  21.             bodyStyle:'padding:5px 5px 0',
  22.             width: 370,
  23.             defaults: {width: 220},
  24.             defaultType: 'textfield',
  25.     
  26.             items: [{
  27.                     fieldLabel: this.firstName,
  28.                     name: 'firstname',
  29.                     allowBlank:false
  30.                 },{
  31.                     fieldLabel: this.lastName,
  32.                     name: 'lastName'
  33.                 },{
  34.                     fieldLabel: this.surnamePrefix,
  35.                     width: 50,
  36.                     name: 'surnamePrefix'
  37.                 },{
  38.                     fieldLabel: this.company,
  39.                     name: 'company'
  40.                 },  new Ext.form.ComboBox({
  41.                     fieldLabel: this.province,
  42.                     hiddenName: 'state',
  43.                     store: new Ext.data.ArrayStore({
  44.                         fields: ['provincie'],
  45.                         data : Ext.exampledata.dutch_provinces // from dutch-provinces.js
  46.                     }),
  47.                     displayField: 'provincie',
  48.                     typeAhead: true,
  49.                     mode: 'local',
  50.                     triggerAction: 'all',
  51.                     emptyText: this.stateEmtyText,
  52.                     selectOnFocus:true,
  53.                     width:190
  54.                 }), {
  55.                     fieldLabel: this.email,
  56.                     name: 'email',
  57.                     vtype:'email'
  58.                 }, new Ext.form.DateField({
  59.                     fieldLabel: this.birth,
  60.                     name: 'birth'
  61.                 })
  62.             ],
  63.     
  64.             buttons: [{
  65.                 text: this.save
  66.             },{
  67.                 text: this.cancel
  68.             }]
  69.         });
  70.         
  71.         Ext.app.ContactForm.superclass.initComponent.apply(this, arguments);
  72.     }
  73. });
  74. Ext.onReady(function(){
  75.     Ext.QuickTips.init();
  76.     // turn on validation errors beside the field globally
  77.     Ext.form.Field.prototype.msgTarget = 'side';
  78.     
  79.     var bd = Ext.getBody();
  80.     
  81.     bd.createChild({tag: 'h2', html: 'Localized Contact Form'});
  82.         
  83.     // simple form
  84.     var simple = new Ext.app.ContactForm();
  85.     simple.render(document.body);
  86. });