2012-03-22 33 views
0
<form name="author-form" accept-charset="utf-8" method="post"> 

<input type="checkbox" id="checklist-1" name="checklist[]" value="0" required /></td> 

<label for="checklist-1">The submission has not been previously published, nor is it before another journal for consideration (or an explanation has been provided in Comments to the Editor).</label> 

<input type="checkbox" id="checklist-2" name="checklist[]" value="1" required /> 
<label for="checklist-2">The submission file is in OpenOffice, Microsoft Word, RTF, or WordPerfect document file format.</label> 

<input type="checkbox" id="checklist-3" name="checklist[]" value="2" required /> 
<label for="checklist-3">Where available, URLs for the references have been provided.</label> 

<input type="checkbox" id="checklist-4" name="checklist[]" value="3" required /> 
<label for="checklist-4">The text is single-spaced; uses a 12-point font; employs italics, rather than underlining (except with URL addresses); and all illustrations, figures, and tables are placed within the text at the appropriate points, rather than at the end.</label> 

<input type="checkbox" id="checklist-5" name="checklist[]" value="4" required /> 
<label for="checklist-5">The text adheres to the stylistic and bibliographic requirements outlined in the <a href="http://42.201.215.2/ojs/index.php/JISRComputing/about/submissions#authorGuidelines" target="_new">Author Guidelines</a>, which is found in About the Journal.</label> 

<input type="checkbox" id="checklist-6" name="checklist[]" value="5" required /> 
<label for="checklist-6">If submitting to a peer-reviewed section of the journal, the instructions in <a href="javascript:openHelp('http://42.201.215.2/ojs/index.php/JISRComputing/help/view/editorial/topic/000044')">Ensuring a Blind Review</a> have been followed.</label> 


<textarea name="commentsToEditor" id="commentsToEditor" rows="3" cols="40" class="textArea" placeholder="Comments to the Editor" required></textarea> 

<input type="submit" name="submit-1" class="btn disabled" value="Continue"> 

</form> 

我想更改提交的CSS類,當所有複選框已被選中並且至少有一個單詞已寫入文本區域時。類應該是這樣的,如果所有的規則都已經滿足,如果一個規則不符合,,那麼就應該再次禁用帶有複選框的jQuery表單驗證

<input type="submit" name="submit-1" class="btn success" value="Continue"> 

我如何定義一個jQuery的功能,只能使提交如果複選框被點擊並且文字已被輸入到textarea中,按鈕?

回答

2

最初禁用提交按鈕,然後附加一個改變事件處理程序的複選框

$(":checkbox,textarea").change(function(){ 
if(($(":checkbox").length== $(":checkbox:checked").length) && $("textarea").val()!=""){ 
    $(":submit").addClass("success").removeAttr("disabled"); 

} 
}); 

DEMO