Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip zero from number attribute value

Tags:

html

I need to set -1 as min and max to 10 in number HTML field. from this I need to skip 0.that is I don't need to submit its value as 0. is this possible in HTML?

 <input type="number" min="-1" max="10"> //I need something like skip = 0
like image 297
Syed mohamed aladeen Avatar asked Jun 06 '16 12:06

Syed mohamed aladeen


2 Answers

You can add pattern attribute and change type to 'text'

<input type="text"  pattern="[1-9]|10|-1">

demo

like image 162
splash58 Avatar answered Nov 14 '22 16:11

splash58


The answer is rather simple on this one.

It's not possible with plain html, since there is no skip="" and pattern="" doesn't work on number inputs. You have to use a Javascript function.

like image 39
luissimo Avatar answered Nov 14 '22 15:11

luissimo