我有 3 个选项卡,这 3 个选项卡有共同的提交和取消按钮。当用户单击提交按钮时,它应该自动切换到已触发验证的选项卡,如何使用以下代码
部分视图实现此功能:服务.cs.html
<script type="text/javascript">
$(document.body).ready(function () {
getService("Test1");
});
function getService(serviceMenuId) {
if (serviceMenuId != undefined && serviceMenuId != '') {
jQuery("div#menubar li").each(function () {
var $li = jQuery(this);
$li.removeClass('sel');
});
document.getElementById(serviceMenuId).className = "sel";
}
$('div#Test1').hide();
$('div#Test2').hide();
$('div#Test3').hide();
$("div#" + serviceMenuId).show();
}
</script>
@using (Html.BeginForm())
{
<div id="Test1" style="position:relative">@{Html.RenderPartial("Test1", Model);}</div>
<div id="Test2" style="position:relative">@{Html.RenderPartial("Test2", Model);}</div>
<div id="Test3" style="position:relative">@{Html.RenderPartial("Test3", Model);}</div>
<div id="saveCancelButton" class="as-ext-form-button-div" style="margin-top: 20px;">
<button title="Click here to save" id="saveData" type="submit" onclick="return attributesValid();">Save</button>
</div>
}