Regular expression in pattern

3

I have an input of type text that I am validating with regular expression, the rule of expression is as follows: it starts with a number between 0 and 2 and then 6 more random numbers, but I do not know why it does not work.

<input pattern="^[0-2][0-9]{6}$" required type="text" class="form-control"/>

Follow the entire code of the page ..

<div class="container">
<div class="row">
  <div class="col-md-12">
     <nav class="navbar navbar-default" role="navigation">
        <div class="navbar-header">
        <a class="navbar-brand" href="">Lista de Serviços</a>
        </div>
        <div class="collapse navbar-collapse">
           <ul class="nav navbar-nav">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown">Selecione o setor <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#">APS</a></li>
                <li><a href="#">GEX</a></li>
                <li><a href="#">Logística</a></li>
                <li><a href="#">Seat</a></li>
              </ul>
            </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
              <li class="dropdown">
                 <a href="" class="dropdown-toggle" data-toggle="dropdown">Login <b class="caret"></b></a>
                 <ul class="dropdown-menu" style="padding: 15px;min-width: 250px;">
                    <li>
                       <div class="row">
                          <div class="col-md-12">
                             <form class="form">
                                <div class="form-group">
                                   <input pattern="^[0-2][0-9]{6}$" required type="text" class="form-control" placeholder="Matrícula" />
                                </div>
                                <div class="form-group">
                                   <input type="password" class="form-control" placeholder="Senha" required />
                                </div>
                                <div class="form-group">
                                   <button type="submit" class="btn btn-success btn-block">Login</button>
                                </div>
                             </form>
                          </div>
                       </div>
                    </li>
                 </ul>
              </li>
             </ul>
           </ul>
        </div>
     </nav>
  </div>

    
asked by anonymous 31.12.2015 / 14:02

1 answer

1

You need to set the first digit as below:

pattern="^[0-2]{1}[0-9]{6}$"
    
31.12.2015 / 23:03