954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

text box validataion

how to make a validation like vb in asp.net? I want to make a text box should only accept numeric values....

samy

samycbe
Newbie Poster
4 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

hi,

To validate the numeric in the TextBox use
:-/

RegularExpressionValidator control
In Properties

Specify the control which control to validate in ControlToValidate Property.

In Text Property Specify any Error Message.


regards
:icon_lol: shailu

manoshailu
Junior Poster
105 posts since Jun 2007
Reputation Points: 34
Solved Threads: 10
 

how to make a validation like vb in asp.net? I want to make a text box should only accept numeric values....

samy


friend may i know what language you are using
you want tovalidate that on client side or server side

vinod varma
Newbie Poster
3 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
 

hi,

Its a server side validation control, this control can be used in VB or C# and one more thing u have to mainly specify the Validation Expression in the control property.

Numeric Validation : \d {3,5} -----> d -Numeric Checking, {} - Size
Character Validation : \D {5,10} -----> D - Character Validation, {} - Size.

Regards
Shailu.:icon_smile:

manoshailu
Junior Poster
105 posts since Jun 2007
Reputation Points: 34
Solved Threads: 10
 

Hi,

I would suggest you to use "MaskedEdit" control from ajax toolkit. here is the link.

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

kedar_challa
Light Poster
47 posts since Nov 2005
Reputation Points: 10
Solved Threads: 1
 

If the intention is only to make the textbox accept only numeric values, just very simply use the Isnumeric function.

that is

if not Isnumeric(textbox.text) then
 'do stuff like forcing retyping of content
end if

Hope this helps.

jamello
Posting Whiz in Training
219 posts since Oct 2006
Reputation Points: 215
Solved Threads: 6
 

HI,
HOPE THE BELOW LINK WILL HELP READERS A LOT FOR CROSS-BROWSER NUMERIC VALIDATION:
http://shawpnendu.blogspot.com/2009/03/cross-browser-javascript-isnumeric.html

mail2saion
Posting Whiz in Training
247 posts since Apr 2009
Reputation Points: 26
Solved Threads: 44
 

mail2saion, many thanks for bumping this thread to promote your blog.

buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

how to make a validation like vb in asp.net? I want to make a text box should only accept numeric values....

samy

Hi,
First of all you need validation for textbox and you want user to enter only numeric values. So rather than allowing user to enter something and check it whether it is numeric or not is not good approach. I believe prevention is better than cure.

So you can Use FilterTextboxExtender that comes with AjaxToolkit. Please have a look at this demo

I hope this will solve your problem. You can use other tools also, they are very useful.

Happy Programming!! :icon_smile:

nil
Light Poster
30 posts since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You