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:
Then you add:VB Code:
var phone = "()- 0123456789"; var numb = "0123456789"; var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; function res(t,v){ var w = ""; for (i=0; i < t.value.length; i++) { x = t.value.charAt(i); if (v.indexOf(x,0) != -1) w += x; } t.value = w; }
This can be found on:Code:onkeyup="res(this,phone);"
http://www.felgall.com/jstip44.htm
Now what would others do?
Woof


Reply With Quote