html input numbers only code example

Example 1: html restrict input to numbers

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

Example 2: html input box integer only

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

Example 3: html5 number integer

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

Example 4: input text tag only input integer number

<input type="text" class="number" />

<script>
function degitOnly(e){
    var unicode = e.charCode ? e.charCode : e.keyCode;
      if (unicode!=8 && unicode!=9)
     {
     	 if (unicode<46||unicode>57||unicode==47)
     		 return false
    }
}

$(".number").inputFilter(function(value) {
    return /^-?\d*$/.test(value);
});
</script>