-1

How can i allow only numbers and dot in input area using patterns and using button

<input type="text" id="amt" name="amount" pattern="[0-9-.]" title="numbers with dot allowed">
<input type="button" value="submit">
Joe Mike
  • 45
  • 6
  • Do you mean there has to be a dot or that it is the only non-numeric character allowed? Maybe you just want to be sure that you can use the value as a number? –  Feb 06 '22 at 14:10
  • yes dot is allowed and numbers only – Joe Mike Feb 06 '22 at 14:12
  • @JoeMike Do I get it right - any numberic value with dot separator is allowed? It cannot just be only dot itself? So for example VALID values are "10.10", "1213.00" but NOT ".", "1.a", "fooo.bar"? – tiblu Feb 06 '22 at 14:21
  • So for example VALID values are "10.10" thats wat i want – Joe Mike Feb 06 '22 at 14:45
  • Here is a simple one which allows for exactly one decimal, but no more: –  Feb 06 '22 at 15:03

1 Answers1

1

This will do:

pattern="[0-9.]"
Henryc17
  • 851
  • 4
  • 16