PDA

View Full Version : [CLOSED] Client Validation



adelaney
Sep 14, 2012, 6:16 PM
I have page which has a mix of controls (some EXT, some not). For the EXT ones, even though the controls are not in an EXT Form, is there a way to generically determine if the controls are in an "error" state - meaning, if a user has typed text in a date type control and the red error indicator is showing, I can generically test for (check something like "App.Errors" - not real, I know, but maybe something like that) on a button click without specifically calling control's function, adding a listner to the control, or looping through each control at button click.

Daniil
Sep 15, 2012, 6:01 PM
Hi,

Please use the ValidityChange event.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Field-event-validitychange


or looping through each control at button click.

A way of looping can depend how the fields are organized.

The simplest way is to place them all into some Ext.NET Container and iterate the items collection.

Container1.items.each(function (item) {
alert(item.isValid());
});

adelaney
Sep 16, 2012, 5:54 AM
When I use my container:


App.searchForm.items
It returns 0.

However, if I use a jQuery statement:

$("input")
I get 71 items.

Would it matter if the first child in my container is a div which has a fieldset where the inputs are children of the fieldset? Is there no generic sort of finding of EXT items as similar to jQuery?

geoffrey.mcgill
Sep 16, 2012, 3:12 PM
Is there no generic sort of finding of EXT items as similar to jQuery?

You can use Ext.select.

http://docs.sencha.com/ext-js/4-1/#!/api/Ext-method-select

Example


Ext.select('input')

Hope this helps.

Daniil
Sep 17, 2012, 5:54 AM
Would it matter if the first child in my container is a div which has a fieldset where the inputs are children of the fieldset

Then this <div> and its content doesn't become items of the container. It is rendered as raw HTML.

I would consider a possibility to avoid this <div> and deal with the Items collection of the Container.

Also I recommend to look into the Ext.ComponentQuery utility class.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.ComponentQuery