<!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"?xml:lang="zh-cn">
<head>
?<meta?http-equiv="Content-Type"?content="text/html;charset=UTF-8"?/>
?<title>網頁標題</title>
?<meta?name="keywords"?content="關鍵字列表"?/>
?<meta?name="description"?content="網頁描述"?/>
?<link?rel="stylesheet"?type="text/css"?href=""?/>
?<style?type="text/css"></style>
</head>
<body>
<form?id="demoForm"?method='post'>
?<fieldset>
?<legend>用戶登錄</legend>
?<p>
??<label?for="username">用戶名</label>
??<input?type="text"?id="username"?name="username">
?</p>
?<p>
??<label?for="password">密碼</label>
??<input?type="password"?id="password"?name="password">
?</p>
?<p>
??<input?type="submit"?value="提交">
?</p>
?</fieldset>
</form>
<script?type="text/javascript"?src="jquery.js"></script>
<script?type="text/javascript"?src="jquery.validate.js"></script>
<script?type="text/javascript">
?$(document).ready(function(){
??$("#demoForm").validate({
???rules:?{
????username:{
?????required:true,
?????minlength:2,
?????maxlength:10
????},
????password:{
?????required:true,
?????minlength:2,
?????maxlength:16
????}
???}??
???messages:?{
????username:{
?????required:"用戶名必須填寫",
?????minlength:"用戶名最少為2字符",
?????maxlength:"用戶名最大為10字符"
????},
????password:{
?????required:"密碼必須填寫",
?????minlength:"密碼最少為2字符",
?????maxlength:"密碼最大為16字符"
????}
???}
??});
?});
</script>
</body>
</html>
2016-06-07
46行少了一個逗號,親測
2015-06-12
你有引入 jquery.js 和jquery.validation.js 嗎?
2015-05-31
你檢查一下你的語法,是中英文的問題不
2015-05-31
46行少了一個逗號