-
20 Feb 2009 12:22 PM #1
Binding Fields to a Form for validation?
Binding Fields to a Form for validation?
Hi All...
I have fields placed around my page using the following:
And the target for these fields are within a label in a form panel:Code:var weekNumField = new Ext.form.NumberField({ id: 'weeklyNum-field', allowDecimals: false, maxValue: 52, minValue: 1, allowNegative: false, allowBlank: false, renderTo:'weeklyNum', name:'RecurEvery', value: '1', width: 25, disabled: true });
When I submit the form, the field is not checked for validity.Code:{ xtype:'label', cls:'x-form-item', html:'Recur every <span id="weeklyNum"></span> week(s) on:' }
If the field is invalid (by simply clicking into the field and leaving it empty) the form will still submit.
Do I need to check for this manually in the listener for the submit button? Or is there some way to bind this field to the form?
Thanks for the help!!
-
20 Feb 2009 12:27 PM #2
No, you don't need to check manually, there are built in validation mechanisms already implemented. The easies one is here: http://examples.extjs.eu/?ex=formloadsubmit You can see that form cannot be submitted with invalid values - you can try to change values in fields after load.
If still in troubles, post a working showcase please.Jozef Sakalos, aka Saki
A lot of valuable info at:
Saki's Extensions and Plugins
Saki's Extensions and Plugins Docs
Saki's Examples, Latest: Grid in Card Layout
Saki's Blog, Featured: Writing a Big Application in Ext, Latest: Grid MultiSearch Plugin Video
-
20 Feb 2009 12:59 PM #3
Thanks for the quick reply!
I understand that the form does check fields automatically.
However, where I'm running into problems is when I create fields outside of the form panel itself.
So I have the form panel, and then create additional fields with the method I mentioned above.
When I submit the form... that field (which exists outside the form panel) is not validated. But it's data is submitted.
I'll post up an example when I get a few free minutes
Thanks again!
-Nick


Reply With Quote