在提交之前禁用空文本字段

Disable empty textfield before Submit

本文关键字:文本 字段 提交      更新时间:2023-09-26

我的搜索表单中有11个文本字段。我想让用户搜索选择属性,剩下的空白。我想在单击"提交"按钮后禁用空文本字段。因为空字段会向我的WFS服务发送一个空字符串。有可能做到吗?

此外,如果没有填写任何字段,我想通知用户。

提前感谢

formPanel = new GeoExt.form.FormPanel({
    ref: "formPanel",
    title:"Wyszukiwarka",
    collapsible: true,
    width: 150,
    region: "west",
    protocol: protocol,
    buttons:[
    {text: 'Czyść',
    width: 60,
handler: function(){
formPanel.getForm().reset();
}},
    {
     text: "Szukaj",
        width: 70,
     handler: function() {
         formPanel.getForm().search();
     },
     //scope: formPanel
 }],
    items: [{
        xtype: "numberfield",
        name: "trans_id__eq",
           cls : 'myCls',
           emptyText:"",
        value: "",
        submitEmptyText: false,
        //fieldLabel: "ID",
        //disabled: true,
    },
    {
        xtype: "textfield",
        name: "dokument__eq",
        // emptyText:"Dokument",
          cls : 'myCls',
        value: "",
        disabled: true,
       // fieldLabel: "nabywca",
            //allowBlank: false
    },
    {
        xtype: "textfield",
        name: "data_transakcji__eq",
           cls : 'myCls',
           //emptyText:"Data Transakcji",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
    {
        xtype: "textfield",
        name: "typ_nier__eq",
           cls : 'myCls',
          // emptyText:"Typ nieruchomości",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
    {
        xtype: "textfield",
        name: "cena_tran__eq",
           cls : 'myCls',
          // emptyText:"Cena transakcji",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
    {
        xtype: "textfield",
        name: "cena_1m2_dlk__eq",
           cls : 'myCls',
           //emptyText:"Cena 1m2",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
    {
        xtype: "textfield",
        name: "pow_m2__eq",
           cls : 'myCls',
           //emptyText:"Powierzchnia",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
    {
        xtype: "textfield",
        name: "sprzedawca__eq",
           cls : 'myCls',
          // emptyText:"Sprzedawca",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
    {
        xtype: "textfield",
        name: "nabywca__eq",
           cls : 'myCls',
          // emptyText:"Nabywca",
        value: "",
        //fieldLabel: "ID",
    disabled: true,
    },
    {
        xtype: "textfield",
        name: "wspx__eq",
           cls : 'myCls',
          // emptyText:"WspX",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    },
        {
        xtype: "textfield",
        name: "wspy__eq",
           cls : 'myCls',
          // emptyText:"WspY",
        value: "",
        //fieldLabel: "ID",
        disabled: true,
    }

    ],
    listeners: {
        actioncomplete: function(form, action) {
        // this listener triggers when the search request
        // is complete, the OpenLayers.Protocol.Response
        // resulting from the request is available
        // through "action.response"
            features = action.response.features;
            app.featureGrid.store.loadData(features);   //załadowanie zwróconego wyniku wyszukiwania do "app.featureGrid.store"
            vm=app.mapPanel.map.getLayersByName("Wynik wyszukiwania");
            if(vm.length==0){
                vecLayer = new OpenLayers.Layer.Vector("Wynik wyszukiwania");
               app.mapPanel.map.addLayer(vecLayer);
                app.featureGrid.store.bind(vecLayer);
                app.featureGrid.getSelectionModel().bind(vecLayer);
            //app.featureGrid.getSelectionModel().bind(vectorLayer);
        }
    }
    }


})

    );

您可以使用字段的submitValue(布尔值)属性来阻止它向服务器提交其值。

您可以将其设置为表单上所有字段的默认值,但如果用户更改了字段值并且它不是空的,则将submitValue更改为true