-
FEATURED COMPONENTS
First time here? Check out the FAQ!
What's the best way to put validation/constraints on a Listbox which is used in "select" mode (i.e: dropdown list) ?
Listbox doesn't have Constraint support like Textbox.
I want to check that the Listbox has a selected item other the first item (first item is empty space "").
I want to have popup error close to the Listbox similar to Textbox error popup.
Regards, cgunadi
Hi cgunadi,
You can override doBlur_ function in client side to show error message as follows:
<zk>
<zscript><![CDATA[
java.util.ArrayList list = new java.util.ArrayList();
list.add("");
list.add("option 1");
list.add("option 2");
list.add("option 3");
org.zkoss.zul.ListModelList model = new org.zkoss.zul.ListModelList(list);
]]></zscript>
<listbox mold="select" model="${model}" xmlns:w="client">
<attribute w:name="doBlur_"><![CDATA[
function(evt) {
this.$doBlur_(evt);
if (this.$n().value == '') {
zAu.wrongValue_(this, 'Please select.....');
} else {
zAu.cmd0.clearWrongValue(this.uuid);
}
}
]]></attribute>
</listbox>
</zk>
Asked: 2013-02-21 18:51:48 +0800
Seen: 114 times
Last updated: Feb 22 '13