PDA

View Full Version : Show valid icon if field is valid.



emredagli
6 Jul 2010, 9:34 PM
Hii,
I try to show user name exist or not on create an account.
So I want to show validity icon on the right side of the textfield on both cases.

Can I do this with ExtJS validation tools or do I need to custom operation?

Thanks in advance.

Larry0ua
17 Mar 2011, 4:34 AM
Hi,

I know it's too late to response but hope that my information may help anyone after me.

Ext.reg('textfieldValidator', Ext.extend(Ext.form.TextField, {
listeners: {valid: function(el) {
if(el.getValue().length>0) {
imgid = Ext.get(el.id).next();
if (imgid) {
imgid.addClass('x-form-valid-icon');
imgid.show();
}}},invalid:function(el){
imgid=Ext.get(el.id).next();
imgid.removeClass('x-form-valid-icon');
},render:function(el){el.markInvalid("Fake message");el.clearInvalid();}},
validator: function(e) {return true;}
}));

- registers new xtype 'textfieldValidator' that will use x-form-valid-icon class for valid fields.
Of course you need to create this class in your css - get example from x-form-invalid-icon records in css and create the same for x-form-valid-icon with changing picture location.

Not sure if there is more easy way to implement this behavior, but it worked for me.

emredagli
20 Mar 2011, 11:35 AM
Thanks for your reply.
I had resolved it in different way.
But your solution is better.
Thanks.