开发者

Ext-JS Form TextArea Validation Q

开发者 https://www.devze.com 2023-02-21 18:44 出处:网络
I\'ve implemented some validation in my form by extending the form.VTypes class to include another vtype that I personally made.However I am unsure if this is the best path to go, for starters I want

I've implemented some validation in my form by extending the form.VTypes class to include another vtype that I personally made. However I am unsure if this is the best path to go, for starters I want to control when the validation happens (onBlur). I want to also display a checkmark when it is valid and have the submit value be disabled until the form is filled out correctly.

I've been digging around to see开发者_如何学Python how the Ext-JS API textfield's validator attribute works, but I can't find a good example of it. Does the validateOnBlur work using it? I'm trying to see how all these different validation attributes / methods are supposed to work together. I don't know what I am supposed to call what when.


EDIT** I have it set now so that the send button is only enabled after it runs isValid(false) on each textfield. Apparently this works for both my VType validation and my allowBlank:false I set. However I do not understand how to execute another method when its actually valid... I saw the valid public event, but I was unsure when I could call it (an example would be awesome)


Something that can get most of what you want done without much effort is using monitorValid: true on the Ext.form.FormPanel, and adding formbind: true to the form's buttons.

new Ext.form.FormPanel({
    monitorValid: true,
    items: [{
            xtype: 'textfield',
            allowBlank: false
            ...
        }, {
            xtype: 'textarea',
            vtype: 'customvtype'
        }],
    buttons: [{
        text: 'Submit',
        formbind: true
    }]
});

When using monitorValid, the form will also fire a clientValidation event that you can use to listen for other actions to perform when the form becomes valid.

0

精彩评论

暂无评论...
验证码 换一张
取 消