<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">
</script>
</head>
<body >
<div id="divi" height="100">
<form class="form-inline" role="form">
<div class="form-group" >
<label class="sr-only" for="em">Email:</label>
<input type="email" id="em" placeholder="Enter email" required >
</div>
<div class="form-group" >
<label class="sr-only" for="pwd">Password:</label>
<input type="password" id="pwd" placeholder="Enter password" required>
</div>
<button type="button" class="btn btn-primary">Login</button>
</form>
</div>
</body>
</html>
您好,请帮我验证带有电子邮件ID的用户ID,密码应该包含大写的小写字母和至少一个字符?
答案 0 :(得分:1)
请遵循本指南:
http://www.webdesignerdepot.com/2012/01/password-strength-verification-with-jquery/
以下是Jquery代码的示例:
//validate letter
if ( pswd.match(/[A-z]/) ) {
$('#letter').removeClass('invalid').addClass('valid');
} else {
$('#letter').removeClass('valid').addClass('invalid');
}
//validate capital letter
if ( pswd.match(/[A-Z]/) ) {
$('#capital').removeClass('invalid').addClass('valid');
} else {
$('#capital').removeClass('valid').addClass('invalid');
}
//validate number
if ( pswd.match(/\d/) ) {
$('#number').removeClass('invalid').addClass('valid');
} else {
$('#number').removeClass('valid').addClass('invalid');
}
[A-Z] 此表达式检查以确保至少输入了一个A到Z(大写)或一个到z(小写)的字母
[A-Z] 此表达式检查以确保至少输入了一个大写字母
\ d 这将检查任何数字0到9