我有以下字段的标签
<div id="tabs">
<ul>
<li><a href="#tabs-1">Tab1</a> </li>
<li><a href="#tabs-2">Tab2</a></li>
<li><a href="#tabs-3">Tab3</a></li>
<li><a href="#tabs-4">Tab4</a></li>
</ul>
<div id="tabs-1">
<b>Name</b>
<input type="text" id="name"><br/>
<b>Age</b>
<input type="text" id="age"><br/>
<input type="submit" value="next" id="submit"/>
</div>
<div id="tabs-2">
<form name="nithin">
</div>
<div id="tabs-3">
<p>Tab3</p>
</div>
<div id="tabs-4">
<p>Tab4</p>
</div>
</div>
<input type="checkbox" name="tabs-2" value="2">tabs-2
<input type="checkbox" name="tabs-3" value="3">tabs-3
<input type="checkbox" name="tabs-4" value="4">tabs-4
<br>
这里tab-1有两个字段。第二个标签必须在完成第一个标签验证后启用。我们可以选中显示/隐藏复选框但不会激活。我怎么能这样做?您可以看到代码DEMO
答案 0 :(得分:2)
在此示例中,input submit
具有类submit
。我还更改了标签ids
(参见小提琴)
FIDDLE http://jsfiddle.net/Spokey/2aQ2g/54/
$('.submit').click(function (e) {
e.preventDefault(); //prevent from submission and do script instead
//validation ....
//if validation is okay, do below
var nexttab = parseInt($(this).parent().next().attr('id').match(/\d+/g), 10);
$('#tabs').tabs("enable", nexttab).tabs("select", nexttab);
$('input[name="tabs-'+nexttab+'"]').removeAttr('disabled').prop('checked', true);
});