你好
提供一个范例 :
http://www.formget.com/jquery-login-form/另外一个范例代码:
<html>
<head>
<meta charset="utf-8">
<title>jQuery Validation Plugin Examples</title>
<!-- Bootstrap CSS used for styling the demo pages-->
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<!-- basic validation of a login form -->
<form class="form" id="example1">
<div class="form-group">
<label>Basic login form example</label>
</div>
<div class="form-group">
<label for="example1-email">Email address</label>
<input type="email" class="form-control" id="example1-email" name="example1-email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="example1-password">Password</label>
<input type="password" class="form-control" id="example1-password" name="example1-password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<!-- Load jQuery and jQuery-Validate scripts -->
<script src="js/jquery.js"></script>
<script src="
http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
// When the document is ready
$(document).ready(function () {
//validation rules
//by default it will append a <label class="error> element to the invalid input
//and will add a "error" class to the input
$("#example1").validate({
rules: {
"example1-email": {
required: true,
email: true
},
"example1-password": {
required: true,
minlength: 5
}
}
});
});
</script>
</body>
</html>
本回答被网友采纳