how to enter only numeric value

Posted by Shoyebaziz123 under ASP.NET on 6/4/2009 | Views : 21182 | Status : [Member] | Replies : 3
Hi friends,
How can i enter numeric value up to two decimal point in textbox ..........




Responses

Posted by: Vuyiswamb on: 6/5/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Morning Shoyebaziz123

A Text Box is of String Data type so it takes anything, but when you want to save it in the Database, you have to do a proper Casting. You asked your question is a very strange way, what i mean you did not give me enough info to answer you. Please Rephrase your question and this time give me info , like e.g "I have this" and i want to achieve this"

Thank you for Posting at Dotnetfunda


Vuyiswa Maseko



Thank you for posting at Dotnetfunda
[Administrator]

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 6/5/2009 [Member] Starter

Up
0
Down
You can use asp:CompareValidator and choose different option from Type and Operator property after specifying the ControlToValidate property to your TextBox.

You need to select Decimal perhaps, for more you can refer to http://www.dotnetfunda.com/tutorials/controls/comparevalidator.aspx

Also you can validate this server side after primarily validating it in client side using above control.

Hope this will give some idea.

Thanks

Regards,
Raja, USA

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Syedshakeer on: 6/8/2009 [Member] Starter

Up
0
Down
Hi Shoyebaziz
use regular Expression validator to allow only Numeric value and up to two decimal Points
below is the Regular Expression which you have to use:

[\d]{1,}.[\d]{2} 


Here \d means it takes only Numeric Values
{1,} means it allows exactly one digit or more than one digit...
after . (dot)decimal we have to use
[\d]{2} means it allows exactly two digits.

eg:
98.34 

8888.00
43433434.09
4.045


Syed Shakeer Hussain

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response