-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How does one validate bandbox , since validation fired on focus off if I'm not mistaken.
This presents following issue for me.
I have a bandbox with list dropdown/popup select from which should set value of bandbox ,
but when I do actual select the validation gets fired before my value is actually set for bandbox , hence I allways get
error.
How to I make sure that validation is only fired after I set bandbox value???
Hi SergeTK,
maybe you should implement your validation logic in onSelect event handler ?
for example:
<bandbox id="bd"> <bandpopup> <listbox width="200px"> <attribute name="onSelect"> if(self.getSelectedIndex() != 1 ){ bd.value= self.selectedItem.label; }; bd.closeDropdown(); </attribute> <listhead> <listheader label="Name"/> <listheader label="Description"/> </listhead> <listitem> <listcell label="John"/> <listcell label="CEO"/> </listitem> <listitem> <listcell label="Joe"/> <listcell label="Engineer"/> </listitem> <listitem> <listcell label="Mary"/> <listcell label="Supervisor"/> </listitem> </listbox> </bandpopup> </bandbox>
Thank you for the reply, but if I do that wouldn't that stop validating the typing into bandbox and only validate the selection??
As it stands right now input can be either typed in by user directly or selected from dropdown.
Hi SergeTK,
you can set readonly="true" in bandbox to prevent user input value by typing:
<bandbox id="bd" readonly="true"> <bandpopup> <listbox width="200px"> <attribute name="onSelect"> if(self.getSelectedIndex() != 1 ){ bd.value= self.selectedItem.label; } bd.closeDropdown(); </attribute> <listhead> <listheader label="Name"/> <listheader label="Description"/> </listhead> <listitem> <listcell label="John"/> <listcell label="CEO"/> </listitem> <listitem> <listcell label="Joe"/> <listcell label="Engineer"/> </listitem> <listitem> <listcell label="Mary"/> <listcell label="Supervisor"/> </listitem> </listbox> </bandpopup> </bandbox>
Hi SergeTk,
I'm sorry to tell you that this is a bug.
http://sourceforge.net/tracker/?func=detail&atid=785191&aid=2307954&group_id=152762
http://sourceforge.net/tracker/?func=detail&atid=785191&aid=2307993&group_id=152762
so the feasible way right now is to write event handler of onSelect event in the listbox inside the bandbox and onChanging event in bandbox to validate user input.
Clarified, the first problem is that we should use
bd.setValue(self.selectedItem.label)
bd.value = self.selectedItem.label;
so if we want to modify the demo code in in developer reference (http://www.potix.com/doc/devref/ch04s02s04.html) to let user only select the third entry "Mary", the code should be:
<bandbox id="bd" constraint="/^M.*/"> <bandpopup> <listbox width="200px"> <attribute name="onSelect"> bd.closeDropdown(); bd.setValue(self.selectedItem.label); </attribute> <listhead> <listheader label="Name"/> <listheader label="Description"/> </listhead> <listitem> <listcell label="John"/> <listcell label="CEO"/> </listitem> <listitem> <listcell label="Joe"/> <listcell label="Engineer"/> </listitem> <listitem> <listcell label="Mary"/> <listcell label="Supervisor"/> </listitem> </listbox> </bandpopup> </bandbox>
Asked: 2008-11-17 03:05:04 +0800
Seen: 348 times
Last updated: Nov 17 '08