我正在使用jQuery驗證插件1.9.0。我已經從這裏下載插件:http://bassistance.de/jquery-plugins/jquery-plugin-validation/jquery numberOfInvalids()函數不工作
我已從此鏈接http://docs.jquery.com/Plugins/Validation/Validator/numberOfInvalids 中複製了以下代碼,以找出我在表單中出現的錯誤數。但它不起作用。
$(document).ready(function() {
$('a.delete').click(function() {
invalidHandler: function() {
$("#summary").text(validator.numberOfInvalids() + " field(s) are invalid");
}
});
});
然後
<div id="summary" class="summary"> </div>
<a href="#" class="delete">click</a>
我的頭格式如下:
<form class="uniform" autocomplete="off" id="myForm" enctype="multipart/form-data" action="<?echo base_url();?>addteacher_salary/add " method="post" name="myForm">
我不叫我的任何形式的驗證功能,我只是裏面裝載頭驗證插件標籤和驗證工作。
你能告訴我代碼有什麼問題嗎?
編輯
我的完整形式看起來像以下:
<form class="uniform" autocomplete="off" id="myForm" enctype="multipart/form-data" action="<?echobase_url();?>addteacher_salary/add " method="post" name="myForm">
<fieldset>
<legend>Select A Teacher</legend>
<dl class="inline">
<dt><label for="teachername">Teacher Name <span class="hello">*</span></label></dt>
<dd>
<?php echo form_dropdown('teacherid', $dropdown_teacher,'', 'class="medium required" id="teacherid"'); ?>
</dd>
<dt><label for="salary_month">Month of Salary <span class="hello">*</span></label></dt>
<dd>
<?php $month_options = array(
'' => 'Select',
'January' => 'January',
'February' => 'February',
'March' => 'March',
'April' => 'April',
'May' => 'May',
'June' => 'June',
'July' => 'July',
'August' => 'August',
'September' => 'September',
'October' => 'October',
'November' => 'November',
'December' => 'December',
);
echo form_dropdown('salary_month', $month_options,'', 'class="medium required"' );?>
</dd>
<dt><label for="salary_year"> Year of Salary <span class="hello">*</span></label></dt>
<dd>
<?php
$year_options = array(
'' => 'Select',
'2010' => '2010',
'2011' => '2011',
'2012' => '2012',
'2013' => '2013',
'2014' => '2014',
'2015' => '2015',
'2016' => '2016',
'2017' => '2017',
'2018' => '2018',
'2019' => '2019',
'2020' => '2020',
'2021' => '2021',
'2022' => '2022',
'2023' => '2023',
'2024' => '2024',
'2025' => '2025',
'2026' => '2026',
'2027' => '2027',
'2028' => '2028',
'2029' => '2029',
'2030' => '2030',
);
echo form_dropdown('salary_year', $year_options,'', 'class="medium required"' );?>
</dd>
<dt><label for="salary_disbursement_date">Salary Disbursement Date <span class="hello">*</span></label></dt>
<dd>
<input type="text" name="salary_disbursement_date" id="datepicker2" maxlength="10" class="medium required" />
</dd>
<dt><label for="salaryamount">Salary Amount <span class="hello">*</span></label></dt>
<dd>
<input type="text" name="salary_amount" id="salary_amount" value="" class="medium required number" />
</dd>
</dl>
<div class="buttons">
<button id="submit_item" name="submit_item" type="submit" class="button">Submit Button</button>
</div>
</fieldset>
</form>
你的表單字段是什麼樣的? – 2011-12-24 00:39:05
@安德魯·惠特克謝謝你的回覆。請檢查上面我的帖子的編輯部分。再次感謝:) – 2011-12-24 00:48:35