ASP.NET MVC学习笔记 (2)
jQuery验证插件使用方法:
1.引用。先引用jQuery,再引用jQuery.validate插件。
<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script> <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
2.验证demo代码。
$(document).ready (function() { // validate signup form on keyup and submit var validator = $("#customerForm").validate //要验证的Form Id ({ rules: { CompanyName: { required: true, minlength: 5 }, ContactName: { required: true } }, messages: { CompanyName: { required: "CompanyName不允许为空!" }, ContactName: { required: "ContactName不允许为空!" } } }); });