0
我的問題是當頁面加載第一次,警報(1)和警報(2)彈出,但當我點擊我的保存按鈕警報(3)不彈出,但顯示驗證消息(如果我填寫正確或錯誤的下拉列表,則不會計量),並保存所有內容。 我有這樣的JS:在asp.net MVC3的Javascript驗證
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
alert(1);
PassWayValidators();
$('#documents_TravelDocumentDocumentPass_PassDate').datepicker();
});
function PassWayValidators() {
alert(2);
$.validator.addMethod('PassWayValidator',
function (value, element) {
alert(3);
}, 'Please Inert Valid Numbers');
$("#documents_TravelDocumentDocumentPass_PassWayId").rules("add", {
PassWayValidator: true
});
}
</script>
<...Some Code Here...>
<div class="TravelDocumentDocumentPassCommentInner">
<span>გადაცემის ფორმა
<br />
@Html.DropDownListFor(model => documents.TravelDocumentDocumentPass.PassWayId, (IEnumerable<SelectListItem>)ViewBag.DocumentPassTypeList, String.Empty, isDisabled)
@Html.ValidationMessageFor(model => documents.TravelDocumentDocumentPass.PassWayId, "*")
</span>
</div>
<...Some Code Here too... and>
@Html.ValidationSummary()
誰能告訴我是什麼問題?