restrict special numbers for input

316 Views Asked by At

I want to restrict special numbers for input, so far I have restricted just symbols and text:

<input type="text" id="txtPageNumber" class="txtPageNumber" onkeyup="this.value = this.value.replace(/[^0-9\.]/g,'')" value="" />

but I want to let people to enter just special numbers, for example: from 1 to 16...

1

There are 1 best solutions below

2
On BEST ANSWER

As you've tagged your question with jQuery, here's how you could use jQuery validation plugin

$("#myform").validate({
  rules: {
    txtPageNumber: {
      required: true,
      range: [1,16]
    }
  }
});