我的漫漫程序之旅

          專注于JavaWeb開發
          隨筆 - 39, 文章 - 310, 評論 - 411, 引用 - 0

          導航

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(39)

          隨筆檔案(43)

          文章分類(304)

          文章檔案(257)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          Ext Form 的 驗 證

          <HTML>
           
          <HEAD>
            
          <TITLE> form練習之驗證 </TITLE>
            
          <link rel="stylesheet" type="text/css" href="../../../resources/css/ext-all.css"/>
            
          <script type="text/javascript" src="../../../adapter/ext/ext-base.js"></script>
            
          <script type="text/javascript" src="../../../ext-all.js"></script>
          <script>
              Ext.onReady(
          function()
              
          {
                  
          //初始化快速提示
                  Ext.QuickTips.init();
                  
          //將提示顯示在form屬性旁邊
                  Ext.form.Field.prototype.msgTarget = 'side';
                  
          //得到body對象
                  var bd = Ext.getBody();
                  
          //創建一個h2標簽
                  bd.createChild({
                      tag : 'h2',
                      html: '
          <a href="#">非常簡單的From</a>'
                  }
          );

                  
          var simple = new Ext.FormPanel({
                      labelWidth : 
          75,
                      url : 'http:
          //www.aygfsteel.com/supercrsky',
                      frame : true,
                      title : '簡單Form',
                      bodyStyle : 'padding : 5px 5px 
          0',
                      width : 
          350,
                      draggable : 
          true,
                      defaults : 
          {width : 230},
                      defaultType : 'textfield',
                      
          //非ajax提交
                      onSubmit: Ext.emptyFn,
                      submit: 
          function()
                      
          {
                          
          this.getForm().getEl().dom.submit();
                      }
          ,

                      items : [
                          
          {
                              fieldLabel : '姓名:',
                              name : 'username',
                              allowBlank : 
          false,
                              blankText : '姓名不能為空'
                          }
          ,
                          
          {
                              fieldLabel : '地址:',
                              name : 'address',
                              maxLength : 
          20,
                              maxLengthText : '您輸入的地址太長'
                          }
          ,
                          
          {
                              fieldLabel : '公司',
                              name : 'company' ,
                              minLength : 
          3 ,
                              minLengthText : '您輸入的公司名稱太短'
                          }
          ,
                          
          {
                              fieldLabel : 'Email',
                              name : 'email',
                              vtype : 'email',
                              vtypeText : '您輸入的郵箱格式不正確'
                          }
          ,
                          
          //時間文本域
                          new Ext.form.TimeField({
                              fieldLabel : 'Time',
                              name : 'time',
                              minValue : '
          8:00am', //最小時間
                              maxValue : '6:00pm', //最大時間
                              increment: 1,    //間隔,單位為分鐘,默認為15分鐘
                              invalidText : '您輸入的時間格式不正確'
                          }
          )
                      ],
                      
                      buttons : [
                          
          {
                              text : '保存',
                              handler : 
          function()
                              
          {    
                                  
          //此方法在Class Ext.form.BasicForm里面,是FormPanel的父類
                                  if(simple.getForm().isValid())
                                  
          {
                                      simple.getForm().getEl().dom.action 
          = 'http://www.aygfsteel.com/supercrsky',
                                      simple.getForm().getEl().dom.submit();    
                                  }

                              }

                          }
          ,
                          
          {
                              text : '取消',
                              handler : 
          function()
                              
          {
                                  simple.getForm().getEl().dom.reset();    
                              }

                          }

                      ]
                  }
          );
                  
          //渲染此form
                  simple.render(document.body);
              }
          );
          </script>
           
          </HEAD>
           
          <BODY>
            
           
          </BODY>
          </HTML>


          posted on 2008-08-26 13:57 々上善若水々 閱讀(3030) 評論(0)  編輯  收藏 所屬分類: JavaScript

          主站蜘蛛池模板: 竹北市| 阜南县| 华池县| 崇信县| 涟源市| 秦皇岛市| 兴隆县| 青田县| 雷山县| 化隆| 伊金霍洛旗| 合作市| 衡水市| 靖远县| 东丽区| 阳泉市| 阿瓦提县| 西乌珠穆沁旗| 连江县| 大同市| 林周县| 睢宁县| 花莲市| 城固县| 鱼台县| 宁城县| 新源县| 资溪县| 浑源县| 濮阳县| 五指山市| 康平县| 临桂县| 安平县| 四会市| 罗甸县| 保靖县| 襄樊市| 长沙县| 施秉县| 永寿县|