Jquery validation in tabbed

陌路散爱 提交于 2019-12-13 07:16:20

问题


Here is what i've been trying.

A form will have three tab ,like the above.

When ever use clicks particular tab and try to fill data,it has validate the empty vaidation for text boxes.

When user clicks the first tab and fill some data in text box id="textbox_four" ,then if he clicks the next tab,it data has to be there in id="textbox_five",the same when he click the third tab,it has to be there in "textbox_six",data has to keep passing.

http://jsfiddle.net/CuA9V/2/

It would be great,if you can shed some light here.

Any help would be appreciated


回答1:


This will keep them all in sync. I think that is what you are asking? lol

$('#textbox_four, #textbox_five, #textbox_six').keyup(function(){
    $('#textbox_four').val($(this).val());
    $('#textbox_five').val($(this).val());
    $('#textbox_six').val($(this).val());
});

Edit: you can check the selected tab during validation as below

$('#submitButton').click(function()
{
    var selected = $("#tabs").tabs('option', 'selected');

    if (selected == 0) {
        // Do this
    } else if (selected == 1) {
        // Do that
    } else if (selected == 2) {
        // Etc
    }
};

Updated: http://jsfiddle.net/trapper/CuA9V/5/




回答2:


Detect the value onkeyup and copy the input to the other text fields:

$('#textbox_four').keyup(function(){

$('#textbox_five').val($(this).val());
$('#textbox_six').val($(this).val());

});



回答3:


You can use this jquery to make it work and look better

http://tympanus.net/codrops/2010/06/07/fancy-sliding-form-with-jquery/



来源:https://stackoverflow.com/questions/10599929/jquery-validation-in-tabbed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!