Regular expressions as attributes

0

Are regular expressions still not well implemented in the browser? In which failure: codepen

<form method="GET" name="formu" id="formu">
   <p>
   <input type="text" name="nombre" pattern="[A-Za-z]" required>
   </p>
   <button type="submit">Enviar</button>
</form>
    
asked by Juan Vargas 16.09.2017 в 02:32
source

1 answer

3

Try adding the symbol + , that is, telling the input field to accept one or more of the characters you have listed in the character class [] .

  

The pattern would look like this: [A-Za-z]+

Example:

<form method="GET" name="formu" id="formu">
  <p>
    <input type="text" name="nombre" pattern="[A-Za-z]+" title="Solo admite letras A-Z y a-z" required>
  </p>
  <button type="submit">Enviar</button>
</form>

Source SO .

    
answered by 16.09.2017 / 18:48
source