Page 1 of 1

Required option for input widget

Posted: Wed Jun 05, 2013 11:49 am
by linb
Original post : http://www.crossui.com/Forum/required-i ... n-t96.html
   
Class('App', 'xui.Com',{
    Instance:{
        iniComponents : function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0))};
            
            append(
                (new xui.UI.ComboInput)
                .setHost(host,"ctl_comboinput7")
                .setLeft(30)
                .setTop(50)
                .setWidth(240)
                .setLabelSize(120)
                .setLabelCaption("Required")
                .setType("none")
                .setTips("Required field")
                .setTipsErr("Must be specified")
                .setTipsOK("OK")
                .setValueFormat("[^.*]")
                .setCustomStyle({"LABEL":{"font-weight":"bold", "color":"#FF0000", "$gradients":""}})
            );
            
            append(
                (new xui.UI.ComboInput)
                .setHost(host,"ctl_comboinput6")
                .setLeft(30)
                .setTop(20)
                .setWidth(240)
                .setLabelSize(120)
                .setLabelCaption("Optional")
                .setType("none")
            );
            
            append(
                (new xui.UI.SButton)
                .setHost(host,"ctl_sbutton6")
                .setLeft(150)
                .setTop(90)
                .setWidth(120)
                .setCaption("Submit")
                .onClick("_ctl_sbutton6_onclick")
            );
            
            return children;
            // ]]Code created by CrossUI RAD Tools
        },
        _ctl_sbutton6_onclick : function (profile, e, src, value){
            var ns = this;
            var v2=ns.ctl_comboinput6.getUIValue();
            var v2=ns.ctl_comboinput7.getUIValue();
            if(!v2){
                xui.message("'Required' field must be specified");
                ns.ctl_comboinput7.activate();
            }
        }
    }
});
Class('App', 'xui.Com',{
    Instance:{
        iniComponents : function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0))};
            
            append(
                (new xui.UI.ComboInput)
                .setHost(host,"ctl_comboinput7")
                .setLeft(30)
                .setTop(50)
                .setWidth(240)
                .setLabelSize(120)
                .setLabelCaption("Required")
                .setType("none")
                .setTips("Required field")
                .setTipsErr("Must be specified")
                .setTipsOK("OK")
                .setValueFormat("[^.*]")
                .setCustomStyle({"LABEL":{"font-weight":"bold", "color":"#FF0000", "$gradients":""}})
            );
            
            append(
                (new xui.UI.ComboInput)
                .setHost(host,"ctl_comboinput6")
                .setLeft(30)
                .setTop(20)
                .setWidth(240)
                .setLabelSize(120)
                .setLabelCaption("Optional")
                .setType("none")
            );
            
            append(
                (new xui.UI.SButton)
                .setHost(host,"ctl_sbutton6")
                .setLeft(150)
                .setTop(90)
                .setWidth(120)
                .setCaption("Submit")
                .onClick("_ctl_sbutton6_onclick")
            );
            
            return children;
            // ]]Code created by CrossUI RAD Tools
        },
        _ctl_sbutton6_onclick : function (profile, e, src, value){
            var ns = this;
            var v2=ns.ctl_comboinput6.getUIValue();
            var v2=ns.ctl_comboinput7.getUIValue();
            if(!v2){
                xui.message("'Required' field must be specified");
                ns.ctl_comboinput7.activate();
            }
        }
    }
});