Christopher Green

Now with more Vitamin C!
posts - 41, comments - 30, trackbacks - 1

Numeric input only for a HtmlInputField

Sometimes a validator control is overkill, especially when you are dynamically creating all your web controls and just want a simple restriction.  Below is a little javascript to require numeric input only:

HtmlInputField myField = new HtmlInputField();

myField.Attributes.Add("onkeyup", "this.value=this.value.replace(/[^\\d]*/gi,\"\");");

 

Print | posted on Thursday, January 12, 2006 11:38 AM |

Feedback

Gravatar

# re: Numeric input only for a HtmlInputField


Thanks!

That just came in really handy.
9/14/2006 11:26 PM | Ab
Comments have been closed on this topic.

Powered by: