我使用下面的代碼進行組合框組驗證,它顯示此字段是必需的。作爲錯誤消息,請輸入。我如何修改下面的代碼來自定義消息。提前致謝。單選按鈕組上的jQuery驗證自定義錯誤消息
$(document).ready(function() {
$('input[name="batches.batch"]').rules("add", "required");//works fine
$('input[name="batches.batch"]').messages("error message1", "error message2");// no effect
});
我的HTML:
<input name="batches.batch" type="radio" value="" />First <br />
<input name="batches.batch" type="radio" value="" />Second<br />
<input name="batches.batch" type="radio" value="" />Third<br />
<input name="batches.batch" type="radio" value="" />Fourth<br />
庫我使用的是:
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.10.1.custom.min.js"></script>
<script type="text/javascript" src="js/custom/jquery.validate.min.js"></script>
?你的代碼看起來像jquery-validate。 – Barmar 2013-03-27 08:15:04
@Barmar我正在使用jquery-validate。 – Visruth 2013-03-27 08:47:39
它不工作,因爲這個插件不包含名爲'.messages()'的這種方法。 – Sparky 2013-03-27 15:00:18