1. #1
    Ext User
    Join Date
    Aug 2007
    Posts
    78
    Vote Rating
    0
    nromanel is on a distinguished road

      0  

    Default 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:

    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
    });
    And the target for these fields are within a label in a form panel:
    Code:
    {
    xtype:'label',
    cls:'x-form-item',
    html:'Recur every <span id="weeklyNum"></span> week(s) on:'  
    }
    When I submit the form, the field is not checked for validity.

    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!!

  2. #2
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,538
    Vote Rating
    380
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    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

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  3. #3
    Ext User
    Join Date
    Aug 2007
    Posts
    78
    Vote Rating
    0
    nromanel is on a distinguished road

      0  

    Default


    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

Thread Participants: 1