2011-03-16 5 views
0

나는이 같은 형태가 선택 체인 : -유효성이

<table border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td><div id="subjectList1"> 
     <select name="language[]" class="required" id="f61"> 
     <option value="" selected="selected">-</option> 
     <option>English</option> 
     <option>Malay</option> 
     <option>Mandarin</option> 
     <option>Tamil</option> 
     <option>Arabic</option> 
     </select> 
    </div></td> 
    <td>&nbsp;</td> 
    <td><select name="spoken[]" class="required"> 
     <option value="" selected="selected">-</option> 
     <option value="Spoken">Spoken</option> 
     <option value="Written">Written</option> 
     <option value="Spoken and written">Spoken and written</option> 
    </select></td> 
    <td>&nbsp;</td> 
    <td><select name="fluency[]" class="required"> 
     <option value="" selected="selected">-</option> 
     <option value="Basic">Basic</option> 
     <option value="Average">Average</option> 
     <option value="Fluent">Fluent</option> 
     <option value="Mother tongue">Mother tongue</option> 
    </select></td> 
    <td>&nbsp;</td> 
    <td><input type="checkbox" value="other" id="showOther1" /></td> 
    <td>&nbsp;</td> 
    <td>Others</td> 
    <td>&nbsp;</td> 
    <td><div id="otherLanguegeReq1"><input type="text" id="language1" style="display:none;" class="required" /></div></td> 
    </tr> 
</table> 
    <br /> 

내가 "[] 이야기"를 dropdown- 유효성을 검사 할 수 있습니다를 & dropdown- "유창은 []"언어 []의 값이 아닌 경우 빈?

이것에 대한 아이디어가 있으십니까? 사전

답변

0

에 대한

덕분에 당신은 확실히 아래 onsubmit 같은 것을 호출 할 수 있습니다 또는 당신이 원하는 때의 유효성을 검사 할 수 있습니다. 각 함수 내에서 필요한 요소를 시각적으로 스타일 지정하기 위해 메시지 또는 .addClass ("incomplete")를 작성할 수 있습니다.


function ValidateInputs() { 
    var complete = true; 
    if($("#f61 option:selected") != ""){ 

    $(".required").each(function() { 
     if ($(this).val().length == 0) { 
     complete = false; 
     } 
    }); 

    if (!complete) { 
     alert("Please ensure that you have completed all required fields."); 
    } 

    } 
    return complete; 
} 
관련 문제