简体   繁体   中英

fuelux tab and wizard form validation

I have make some custom wizards on FUELUX, and it can display in this link http://jsfiddle.net/L3b9E/2

the question is, I dont get any idea how to fix the form validation on every step in wizards and separated by tabs. because the validation is not works in second, third, etc tabs.

any idea..?

the jquery code :

var $nextText;
$(document).on('click','[data-wizard]',function(e){
    var $this=$(this),href;
    var $target=$($this.attr('data-target')||(href=$this.attr('href'))&&href.replace(/.*(?=#[^\s]+$)/,''));
    var option=$this.data('wizard');
    var item=$target.wizard('selectedItem');
    var $step=$target.next().find('.step-pane:eq('+(item.step-1)+')');
    !$nextText&&($nextText=$('[data-wizard="next"]').html());
    var cek = 0, $data=[],$e=[],$v=[], $lokasi = $this.attr('lokasi'); //means path to save file

    if(option == "next"){
        $step.find(':input[data-required=true]').each(function(){
            $(this).jinForm('validate');
            if($(this).jinForm('isValid') != true){
                cek = 0;
            }else{
                cek = 1;
                $e.push($(this).attr('id'));
                $v.push($(this).val());

                $data.push($(this).serialize());
            }
        });
        alert($data);
    }

    if(cek == 0){
        return false;
    }else{
        $.post($lokasi,{e:$e,v:$v},function(hasil){ jin.alert(hasil);
            if(hasil==0){
                jin.alert("Saving Data, <b class='text-danger'>Error..!!!</b>");
                return false
            }else{
                $target.wizard(option);
                var activeStep=(option=="next")?(item.step+1):(item.step-1);
                var prev=($(this).hasClass('btn-prev')&&$(this))||$(this).prev();
                var next=($(this).hasClass('btn-next')&&$(this))||$(this).next();
                prev.attr('disabled',(activeStep==1)?true:false);
                next.html((activeStep<$target.find('li').length)?$nextText:next.data('last'));
            }
        }).error(function(){ jin.alert("Save Target Path is <b class='text-danger'>Not Exist</b>..!"); });
    }
});

A similar scenario was discussed here . It should provide some insights. If not please provide additional details for your use case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM