Introduction
Only allowed number in textbox using jquery. Add 'numberonly' class to text control then it will only allow number.
Code
- $(document).ready(function () {
- $('.numberonly').keypress(function (e) {
- var charCode = (e.which) ? e.which : event.keyCode
- if (String.fromCharCode(charCode).match(/[^0-9]/g))
- return false;
- });
- });