Limiting input tag to numbers without using html 5 type=”number”

The reason for this post is due to the fact that not all major browsers support HTML input types yet.

 

This example limits the input to numbers.

<input onkeypress=’return event.charCode >= 48 && event.charCode<=57′>

 

This example limits the input to numbers, but, decimal works.

<input onkeypress=’return (event.charCode >= 48 && event.charCode<=57) || event.charCode==46′ >

Updated: September 15, 2016 — 9:27 am

Leave a Reply

Your email address will not be published. Required fields are marked *