PDA

View Full Version : Field - Validity state



fadjs
29 Jul 2014, 1:10 AM
Hi,
I'm using field.isValid function to know the validity state of a field (textfield, datefield, etc..).


After call to the function field.isValid, if the field is invalid, it is marked graphically as invalid (red rectangle - show attached screenshot).


Is it possible to prevent that the field is graphically updated? I need to know only the validity state for my application logic.

Thanks,
Fad.

chramer
29 Jul 2014, 5:47 AM
isValid (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.Basic-method-isValid)( ) : Boolean (http://docs.sencha.com/extjs/4.2.2/#!/api/Boolean)
Returns true if client-side validation on the form is successful. Any invalid fields will be marked as invalid. If you only want to determine overall form validity without marking anything, use hasInvalidField (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.Basic-method-hasInvalidField) instead.

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.Basic-method-hasInvalidField

fadjs
29 Jul 2014, 7:33 AM
Hi,
I wanted to know if it's possible to get the validation state of single field (always without changing the GUI), and not if there are invalid fields in the form.

Any idea..?

Best regards,
Fad.

chramer
29 Jul 2014, 11:52 AM
Take a look at this property:
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.Labelable-cfg-preventMark

fadjs
30 Jul 2014, 7:08 AM
Hi,
preventMark is a fantastic config options.. :-) it can be also changed at runtime.
I used it as ExtJS does in the following function and all work well.




/**
* Returns true if the form contains any invalid fields. No fields will be marked as invalid
* as a result of calling this; to trigger marking of fields use {@link #isValid} instead.
*/
hasInvalidField: function() {
return !!this.getFields().findBy(function(field) {
var preventMark = field.preventMark,
isValid;
field.preventMark = true;
isValid = field.isValid();
field.preventMark = preventMark;
return !isValid;
});
},



Thanks for your help!!
Fad.