当提交的时候才会去验证,下一篇将介绍单个自动验验
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>验证表单</title>
<style type="text/css">
.error{color:red;}
</style>
<script type="text/javascript" src="misc/js/jquery.min.js"></script>
<script type="text/javascript" src="misc/js/jquery.form.js"></script>
<script type="text/javascript" src="misc/js/jquery.validate.js"></script>
<script type="text/javascript">
$(function(){
$("#validataForm").validate();
})
</script>
</head>
<body>
<form id="validataForm" action="">
<div>
<label for="cname" >用户名</label>
<input type="text" name="cname" />
<label class="error" for="cname">必须不为空</label>
</div>
<div>
<label for="cemail">邮箱</label>
<input type="text" name="cemail" />
<label class="error" for="cemail">请输入正确的邮箱地址</label>
</div>
<div>
<label for="curl">个人主页</label>
<input type="text" name="curl" />
<label class="error" for="curl">请输入正确的url地址</label>
</div>
<div><input type="submit" /></div>
</form>
</body>
</html>