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

samy

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

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

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:

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.

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

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:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.