Hello people, I ask for help!

It is necessary to set pattern in input 'e.

input should not allow input only zeros:

0; 000

input can allow the input of characters and numbers:

abc0; 0abv; 123abv; abv0123

  • Hi, how are you? - Mr. Black
  • @maxnemo, so check that there is at least one valid non-zero character and everything is ok. - Visman
  • pattern /^[?0₽ (.*?)/ in my way it is set, right now I’ll check - Vanya Avchyan
  • Check for a mismatch pattern /^0+$/ - andy.37

2 answers 2

Here is a solution:

  <form name="test" method="get" action="#"> <p><b>Ваше имя:</b><br> <input type="text" size="40" pattern=".*[1-9A-Za-zА-Яа-яЁё].*" placeholder="Минимум 1 буква или цифра от 1 до 9" required> </p> <input type="submit" value="Отправить"> </form> 

If only Russian and Latin letters and numbers are allowed, then this option:

  <form name="test" method="get" action="#"> <p><b>Ваше имя:</b><br> <input type="text" size="40" pattern="(?=.*[1-9A-Za-zА-Яа-яЁё])[\dA-Za-zА-Яа-яЁё]+" placeholder="Только буквы и цифры" required> </p> <input type="submit" value="Отправить"> </form> 

    still so advised me, shortly :)

     pattern="(?!0+$)[\D0-9]+" 
    • one
      The pattern will skip 0.00 . - Visman
    • It is unlikely that a newline character is possible in the input field. [\D0-9] can be replaced by a [\D0-9] . - Wiktor Stribiżew