Reputation: 1579
i validation form like this:
this is my code:
<input type="number" required min="1" step="1" pattern="^(\d+\.)?\d+$" />
how pattern to prevent that?
Upvotes: 0
Views: 51
Reputation: 346
From what I checked, it seems that it may depend on browser. With following pattern, Chrome allows numbers only, Firefox marks numbers with coma or dot as invalid and IE allows [a-z] as well.
^([1-9]|\.|\,)+([0-9])*(\.|\,)?([0-9])*$
I would add onchange
event and set it up with javascript, because I can't see pattern, which will allow/disallow 0 based on first character and will remove browsers differences. 0,1 is still number.
Upvotes: 1