<html>
<head>
<meta charset=utf-8" />
<title>HTML5新增表单属性</title>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/lib/jquery.js"></script>
<script src="http://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
</head>
<body>
<form action="HTML5Structure.html" id="commentForm">
用户名:<input type="text" name="userName" pattern="[A-z]{5,}" title="只能是五位以上英文字符" required /><br />
密码:<input type="password" name="userPwd" placeholder="请输入密码" title="密码不能为空" required /><br />
<input type="submit" value="注册"/>
</form>
<script type="text/javascript">
$(function(){
$("#commentForm").validate()
})
</script>
</body>
</html>
复制以上代码,看看是不是满足你的需求