Bootstrap number validation -
i'm having bootstrap , have problem validation. need input positive integer. how implement it?
for example:
<div> <input type="number" id="replynumber" data-bind="value:replynumber" /> </div>
it's not twitter bootstrap specific, normal html5 component , can specify range min
, max
attributes (in case first attribute). example:
<div> <input type="number" id="replynumber" min="0" data-bind="value:replynumber" /> </div>
i'm not sure if integers allowed default in control or not, else can specify step
attribute:
<div> <input type="number" id="replynumber" min="0" step="1" data-bind="value:replynumber" /> </div>
now numbers higher (and equal to) 0 can used , there step of 1, means values 0, 1, 2, 3, 4, ... .
an example: http://jsfiddle.net/dcpgw/.
be aware: not browsers support html5 features, it's recommended have kind of javascript fallback (and in back-end too) if want use constraints.
for list of browsers support it, can @ caniuse.com.
Comments
Post a Comment