HTML5 使用特定规则进行验证

HTML5 Validation with Certain Rules

如何使用以下规则在 HTML5 中编写验证?

示例:

ab12345, xy56879, pm30075

HTML

<form action="" method="post">
  <div>
    <label for="userid">User ID:</label>
    <input type="text" name="userid" class="form-control" value="" required  pattern="[A-Za-z]{2}+[0-9]{5}" title="User ID" aria-required="true" placeholder="Eg: ab12345">
  </div>
  <br>
  <div>    
  <label for="email">Email Address:</label>
  <input type="text" name="email" value="" required  title="Email" aria-required="true" placeholder="hello.world@happyworld.com">
  </div>
  <button type="submit">Submit</button>
</form>

我希望下面的模式能行得通

pattern="(?=.*[A-Za-z]{2})(?=.*[0-9]{5}).{7,7}"

DEMO HERE

只需从您的模式中删除 +

input:invalid { outline: 1px solid red }
<input type="text" pattern="[A-Za-z]{2}[0-9]{5}" required="true" placeholder="Eg: ab12345">