---
title: "Ext 提交一个Form到Servlet"
author: "hwpok"
date: "2008-11-09T01:38:00Z"
tags: []
slug: "ext-form-servlet"
draft: false
lastmod: "2008-11-09T01:38:00Z"
id: 615796
url: "https://hwpok.iteye.com/blog/615796"
---

function myForm\_1() {  
    Ext.QuickTips.init();  
    Ext.lib.Ajax.defaultPostHeader += '; charset=utf-8'  
    var form = new Ext.FormPanel({  
        frame : true,  
        width : 300,  
        monitorValid : true,// 绑定验证  
        layout : "form",  
        labelWidth : 70,  
        title : "添加个人信息",  
        labelAlign : "left",  
        renderTo : Ext.getBody(),  
        submit : function() {  
            this.getEl().dom.action = '/ext/servlet/Login.do', this.getEl().dom.method = 'POST', this  
                    .getEl().dom.submit();  
        },  
        items : [{  
                    xtype : "textfield",  
                    fieldLabel : "用户名",  
                    id : "userName",  
                    allowBlank : false,  
                    blankText : "不能为空，请正确填写",  
                    name : "userName",  
                    anchor : "90%"  
                }, {  
                    xtype : "textfield",  
                    fieldLabel : "昵称",  
                    id : "smallName",  
                    name : "smallName",  
                    anchor : "90%"  
                }, {  
                    xtype : "datefield",  
                    fieldLabel : "注册日期",  
                    id : "regDate",  
                    name : "regDate",  
                    anchor : "90%"  
                }],  
        buttons : [{  
                    text : "确定",  
                    handler : function() {  
                        form.form.submit();  
                    },  
                    formBind : true  
                }, {  
                    text : "取消",  
                    handler : function() {  
                        form.form.reset();  
                    }  
                }]  
    });  
}  
Ext.onReady(myForm\_1);