2014-03-05 74 views
0

我在我的网页四个选项卡与thier相应字段... 如果选择一个特定的标签则只有标签,我想在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

你可以检查你的病情,我想验证功能 内就提交方法

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() 
{ 

} 

它有点艰难的过程,但你可以很容易地编写它...

+0

,现在我怎么会检查事件是否相应FIEL ds是空的还是不是?? – user3381985

+0

你可以在他们的验证方法中编写你对tab的相应字段的验证...对于验证过程你可以在这里看到... http://stackoverflow.com/a/17804733/2782669 –