input type number code example

Example 1: html input integer and positive

<input type="number" min="0" step="1" />

Example 2: html restrict input to numbers

<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" />

Example 3: html input types

<form>
  <input type="button">
  <input type="checkbox">
  <input type="color">
  <input type="date">
  <input type="datetime-local">
  <input type="email">
  <input type="file">
  <input type="hidden">
  <input type="image">
  <input type="month">
  <input type="number">
  <input type="password">
  <input type="radio">
  <input type="range">
  <input type="reset">
  <input type="search">
  <input type="submit">
  <input type="tel">
  <input type="text">
  <input type="time">
  <input type="url">
  <input type="week">
</form>

Example 4: form with number input html

<input id="number" type="number" value="42">

Example 5: html input box integer only

<input type="number" name="someid" />

Example 6: input type=number 01

//How to make a number field with always 2 numbers displayed : 01, 02, 03 ...-->
<input id="" type="number" min="1" max="99" step="1" onchange="if(parseInt(this.value,10)<10)this.value='0'+this.value;" />