I have a textbox called txtCapacity.

I would like this to be limited to 3 numerical chars...ie number range from 0 to 999.
I can use a RegularExpressionValidator control and set it's ValidationExpression to \d{3}.
However, I would prefer it if I wasn't allowed to enter the word "Woof" at all, as using the above it only traps this on postback.

I have the following JS:
VB Code:
  1. var phone = "()- 0123456789";
  2. var numb = "0123456789";
  3. var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
  4. function res(t,v){
  5. var w = "";
  6. for (i=0; i < t.value.length; i++) {
  7. x = t.value.charAt(i);
  8. if (v.indexOf(x,0) != -1)
  9. w += x;
  10. }
  11. t.value = w;
  12. }
Then you add:
Code:
onkeyup="res(this,phone);"
This can be found on:

http://www.felgall.com/jstip44.htm

Now what would others do?

Woof