0

How to do Listbox contraint/validation

asked 2013-02-21 18:51:48 +0800

cgunadi gravatar image cgunadi
0

updated 2013-02-21 20:23:00 +0800

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

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-02-22 02:51:19 +0800

vincentjian gravatar image vincentjian
2245 6

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>
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2013-02-21 18:51:48 +0800

Seen: 114 times

Last updated: Feb 22 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More