我的页面中有四个标签及相应的字段... 我想如果选择一个特定的选项卡,那么我只想在javascript中验证该选项卡的字段
<div class="tabcontents">
<div id="view1">
<table >
<tr>
<td width="293"><span style="color:red;font-weight:bold">**</span>Plan Name:</td><td colspan="3">
<input type="text" name="planName" id="planName" value=""/></td>
<td width="172"><span style="color:red;font-weight:bold">**</span>Price:</td><td width="262" colspan="3">
<input type="text" name="price" id="price" value=""/></td>
</tr>
<tr><td width="172"><span style="color:red;font-weight:bold">**</span>Billing Code:</td><td width="262" colspan="3">
<input type="text" name="billingCode" id="billingCode" value=""/></td></tr>
</table>
</div>
<div id="view2">
<table width="936">
<tr>
<td width="137">Group Id:</td><td colspan="3">
<input type="text" name="groupId" id="groupId" value=""/></td>
<td width="194">Group Primary CTN:</td><td width="263" colspan="3">
<input type="text" name="groupPrimaryCTN" id="groupPrimaryCTN" value=""/></td>
</tr>
</table>
</div>
答案 0 :(得分:0)
您可以检查验证功能中的条件 在提交方法上发表一个事件
function checkValidation()
{
var returnValue=false;
//make four different condition for all tabs ..like
if( document.getElementById("view1").style.display == "none" )
{
returnValue = validationForTab1();
} else if (document.getElementById("view2").style.display == "none")
{
returnValue = validationForTab2();
} else if (document.getElementById("view3").style.display == "none")
{
returnValue = validationForTab3();
} else if (document.getElementById("view4").style.display == "none")
{
returnValue = validationForTab4();
}
return returnValue ;
}
validationForTab1()
{
}
validationForTab2()
{
}
validationForTab3()
{
}
validationForTab4()
{
}
这个过程有点难,但你可以轻松编写代码......