jQuery.validity 是一個優雅的、功能強大的jQuery表單驗證插件,用來實現表單的數據驗證,無需服務器端支持。是一個簡單好用的jquery表單驗證插件。
<html>
<head>
<title>Simple</title>
<link type="text/css" rel="Stylesheet" href="../../jquery.validity.css" />
<script type="text/javascript" src="../../jquery.js"> </script>
<script type="text/javascript" src="../../jquery.validity.js"> </script>
<script type="text/javascript">
$(function() {
$("form").validity(function() {
$("#vehicles")
.require()
.match("number")
.range(4, 12);
$("#dob")
.require()
.match("date")
.lessThanOrEqualTo(new Date());
});
});
</script>
</head>
<body>
<form method="get" action="simple.htm">
Number of Vehicles:
<input type="text" id="vehicles" name="vehicles" title="Vehicle Count" />
<br /><br />
Date of birth:
<input type="text" id="dob" name="dob" title="Birthday" />
<br /><br />
<input type="submit" />
</form>
</body>
</html>
參考validity.thatscaptaintoyou.com