html5试图添加密码要求标题

时间:2016-07-25 20:18:11

标签: html forms validation

我想在第二个密码框下面有一个要求标题,但是标题是'似乎没有为我工作..

<form action="register.php" method="post">
    <p>
        First Name: 
        <input type="text" name="first_name" size="15" maxlength="20" required pattern="[a-zA-Z]+" required oninvalid="this.setCustomValidity(this.willValidate?'':'Please enter first name')"></input>
    </p>
    <p>
        Last Name: 
        <input type="text" name="last_name" size="15" maxlength="40" required pattern="[a-zA-Z]+" oninvalid="this.setCustomValidity(this.willValidate?'':'Please enter last name')"></input>>
    </p>
    <p>
        Email Address: 
        <input type="email" name="email" size="20" maxlength="60" required oninvalid="this.setCustomValidity(this.willValidate?'':'Please enter a vaild email')"></input>
    </p>
    <p>
        Password: 
        <input type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" name="pass1" onchange="form.pass2.pattern = this.value;" size="10" maxlength="20" required oninvalid="this.setCustomValidity('Please Enter a valid password')"></input>
    </p>
    <p>
        Confirm Password: 
        <input type="password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" name="pass2" size="10" maxlength="20" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters">
    </p>
    <p>
        <input type="submit" name="submit" value="Register" />
    </p>
</form>

1 个答案:

答案 0 :(得分:0)

我想我是在思考这个问题。我只是在表单中添加了它并显示了文本。

密码必须包含至少一个数字和一个大写和小写字母,以及至少8个或更多字符