问答详情
源自:1-2 如何开始及举例

你看~代码没错啊

<!DOCTYPE html>

<html>


<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>jQuery动画特效</title>

<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">

</head>


<body>

<form id="demoForm">

<fieldset>

<legend>用户登录</legend>

<p>

<label for="username">用户名</label>

<input type="text" id="username" name="username" />

</p>


<p>

<label for="password">密码&nbsp;</label>

<input type="num" id="password" name="password" />

</p>

<p>

<input type="submit" name="" id="" value="登录" />

</p>

</fieldset>

</form>

</body>

<script type="text/javascript" src="jquery-1.12.0.min.js" ></script>

<script src="jquery-validation-1.14.0/dist/jquery.validate.js"></script>

<script>

$(document).ready(function(){

$("#demoForm").validate({

rules:{

username:{

require:true,

minlength:2,

maxlength:10

},

password:{

require:true,

minlength:2,

maxlength:16

}

}

});

});

</script>

</html>

提问者:莫小北没有故事 2016-01-23 16:11

个回答

  • 小红1995
    2016-01-24 14:34:22

    是required吧,你少了个d