Tuesday, February 12, 2008

Restrict the contents of a textbox in asp.net 2.0 (VB) form to a numerical value of no more than two decimal places.

Practical Issue:

I am building an asp.net 2.0 application using vb.net and I would like to restrict the input of a series of textboxes to a numerical input of no more than two decimal places - any idea how to go about it? I think it might be possible with javascript but I'm a little rusty, anyone know how to do it?

My Suggestion:

You can do it very easly and effectivly using AJAX Tool kit MaskedEdit or FilteredTextBox. Please check the following links :

http://ajax.asp.net/ajaxtoolkit/MaskedEdit/MaskedEdit.aspx
http://ajax.asp.net/ajaxtoolkit/FilteredTextBox/FilteredTextBox.aspx

You can do this by just adding the ajax controls to your project. If you are new to AJAX, please follow these links :
http://ajax.asp.net
http://ajax.asp.net/ajaxtoolkit

There are good tutorials available to start. Any way it worth to use AJAX Tool kits, as you are using ASP.net 2.0.

No comments: