Featured post
javascript - extjs vtype does not work on textarea -
ok , have vtype enslish , sign looks this:
ext.apply(ext.form.vtypes, { excel: function (v) { return /^.*.(xls)$/.test(v); }, exceltext: 'must *.xls file', englishonly: function (v) { return /^[a-z0-9,\.\~\!\@\#\$\%\^\&\*\(\)\_\+\<\>]*$/.test(v); }, englishonlytest: 'must english letters'
});
now have form looks this:
new ext.formpanel({ id: 'add-label-form', url: hp, frame: true, baseparams: { actionname: 'addlable' }, defaulttype: 'textfield', labelwidth: 70, items: [{ id: 'tbkey', fieldlabel: localize.key, allowblank: false, name: 'tbkey', anchor: '100%' }, { id: 'tbhebrewtran', fieldlabel: localize.hebrew, allowblank: false, name: 'tbhebrewtran', anchor: '100%' }, { id: 'tbenglishtran', fieldlabel: localize.english, allowblank: false, name: 'tbenglishtran', anchor: '100%' }, { id: 'tbdescription', xtype: 'textarea', vtype:'englishonly', fieldlabel: localize.description, allowblank: true, name: 'tbdescription', anchor: '100%' }], buttons: [{ text: localize.submit, formbind: true, handler: onaddlabelsubmitclick }, { text: localize.reset, handler: function () { var f = ext.getcmp('add-label-form').getform(); f.reset(); } }] })
the vtype handler called , returns false expected form still valid , no alert displayed on screen... why that?
make sure include monitorvalid: true
in formpanel
config.
here's comment api explains config option in more detail:
monitorvalid : boolean
if true, form monitors valid state client-side , regularly fires clientvalidation event passing state.
when monitoring valid state, formpanel enables/disables of configured buttons have been configured formbind: true depending on whether form valid or not. defaults false.
with set should see button enabled/disabled , red outline around whatever field vtype
applied to.
update:
i noticed text variable englishonly
defined englishonlytest, , think should defined englishonlytext (you spelled "test" instead of "text"). if recall correctly framework expects see text appended string want use returned text. may why you're not seeing red outline or popup text.
- Get link
- X
- Other Apps
Comments
Post a Comment