2014-03-05 102 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 –