I have an input filed with a class called restrict-numbers which i want to restrict the entered characters to only accept numbers, i used the following code which is great b
$(".numbersOnly").bind('paste', function(e) {
var self = this;
setTimeout(function(e) {
var val = $(self).val();
if (val != '0') {
var regx = new RegExp(/^[0-9]+$/);
if (!regx.test(val)) {
$(".numbersOnly").val("");
}
$(this).val(val);
}
}, 0);
});