Javascript number input field only and does not accept negative and string value

Html input field which will take only number input and will not accept negative number and string input. It will accept only numeric value.

Example:

<input id=”myNumber” type=”number” name=”my_number”  min=”0″ oninput=”this.value = (isNaN(Math.abs(this.value)))?0:Math.abs(this.value)”>

Above example will not take any negative number input and string input. It will accept only positive number.

Leave a Reply