English 中文(简体)
需要加强对口号进行高级核实,以加强批号4
原标题:Advanced VType for password verification on extjs4 enhancement needed

I want to implement a password verification using advanced VType on extjs taken from http://dev.sencha.com/deploy/ext-4.0.2a/examples/form/adv-vtypes.html, but look like the confirm password text field does not validate on the change of password text field if the password confirm doesn t have values (if password value is test and confirm password value is blank then the form is valid). I m sure this is not a right thing. How to make/force the confirm password text field to be valid/invalid by following condition:

  1. If password value not equal to confirm password value then confirm password is invalid (even if confirm password value is blank)
  2. If password value is blank and confirm password value is blank to then confirm password is valid
  3. If password value is equal to confirm password value then confirm password is valid

谢谢。

最佳回答

Ok look like I ve solved my own problem. As Molecule Man said it s cannot be achieved (easily).

我必须超越“Ext.form.field”。 文本。 无法解决这一问题

Ext.form.field.Text.override({
    getErrors: function(value) {
        var me = this,
            errors = me.callParent(arguments),
            validator = me.validator,
            emptyText = me.emptyText,
            allowBlank = me.allowBlank,
            vtype = me.vtype,
            vtypes = Ext.form.field.VTypes,
            regex = me.regex,
            format = Ext.String.format,
            msg;

        value = value || me.processRawValue(me.getRawValue());

        if (Ext.isFunction(validator)) {
            msg = validator.call(me, value);
            if (msg !== true) {
                errors.push(msg);
            }
        }

        if (value.length < 1 || value === emptyText) {
            if (!allowBlank) {
                errors.push(me.blankText);
            }
            //FIX BY ME : NEED TO COMMENT THIS BECAUSE ITS CAN IGNORING VTYPE AS ITS IMMEDIATELY RETURN ERRORS
            //return errors;
        }

        if (value.length < me.minLength) {
            errors.push(format(me.minLengthText, me.minLength));
        }

        if (value.length > me.maxLength) {
            errors.push(format(me.maxLengthText, me.maxLength));
        }

        if (vtype) {
            if(!vtypes[vtype](value, me)){
                errors.push(me.vtypeText || vtypes[vtype + Text ]);
            }
        }

        if (regex && !regex.test(value)) {
            errors.push(me.regexText || me.invalidText);
        }

        return errors;
    }
});

http://jsfiddle.net/gajahlemu/SY6WC/“rel=“nofollow” http://jsfiddle.net/gajahlemu/SY6WC/

问题回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签