473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

validating a textbox

i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.

Nov 17 '05 #1
6 2303
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan
"Newbie" wrote:
i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.

Nov 17 '05 #2
it's not allowing whole nos.

"Brendan Grant" wrote:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan
"Newbie" wrote:
i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.

Nov 17 '05 #3
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan
"Newbie" wrote:
it's not allowing whole nos.

"Brendan Grant" wrote:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan
"Newbie" wrote:
i have a textbox in a c# asp.net webform. i am using a
regularexpressionvalidator control to validate the textbox. only whole nos.
and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
allow whole nos., one decimal pt. and 2 decimal pt.). in my
regularexpressionvalidator control property window, i couldnt find the right
validation expression to use to make it work properly.

thanks in advance.

Nov 17 '05 #4
it's not allowing x.xx such as 5.25

"Brendan Grant" wrote:
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan
"Newbie" wrote:
it's not allowing whole nos.

"Brendan Grant" wrote:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan
"Newbie" wrote:

> i have a textbox in a c# asp.net webform. i am using a
> regularexpressionvalidator control to validate the textbox. only whole nos.
> and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
> allow whole nos., one decimal pt. and 2 decimal pt.). in my
> regularexpressionvalidator control property window, i couldnt find the right
> validation expression to use to make it work properly.
>
> thanks in advance.
>

Nov 17 '05 #5
I apologize again, it seems that I missed a character when updating the regex
string for you, namely a *, so we go from:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$
to
^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]*)|(([-]|[0-9])[0-9]*)+$

Brendan
"Newbie" wrote:
it's not allowing x.xx such as 5.25

"Brendan Grant" wrote:
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan
"Newbie" wrote:
it's not allowing whole nos.

"Brendan Grant" wrote:

> Give this one a try:
>
> ^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$
>
> Brendan
>
>
> "Newbie" wrote:
>
> > i have a textbox in a c# asp.net webform. i am using a
> > regularexpressionvalidator control to validate the textbox. only whole nos.
> > and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
> > allow whole nos., one decimal pt. and 2 decimal pt.). in my
> > regularexpressionvalidator control property window, i couldnt find the right
> > validation expression to use to make it work properly.
> >
> > thanks in advance.
> >

Nov 17 '05 #6
its now working:

^([$]?\d+(\.\d{2})?$)|([$]?\d+(\.\d{1})?$)

thanks

"Brendan Grant" wrote:
Oops, then we need to throw in an or and the real number pattern of
([-]|[0-9])[0-9]* resulting in:

^(([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9])|(([-]|[0-9])[0-9]*)+$

Brendan
"Newbie" wrote:
it's not allowing whole nos.

"Brendan Grant" wrote:
Give this one a try:

^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$

Brendan
"Newbie" wrote:

> i have a textbox in a c# asp.net webform. i am using a
> regularexpressionvalidator control to validate the textbox. only whole nos.
> and currencies are allowed in it (example: 51, 36.3 and 19.95, it should
> allow whole nos., one decimal pt. and 2 decimal pt.). in my
> regularexpressionvalidator control property window, i couldnt find the right
> validation expression to use to make it work properly.
>
> thanks in advance.
>

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alex Bink | last post by:
Hi, I have a validating event on a textbox in which I want to prevent the user to leave the textbox without entering the right data. Only if he clicks on another specific control he is allowed...
2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
6
by: Ryan | last post by:
I have a windows form that I want to force validation on controls (text boxes) when the user clicks a "Save" button. The only way I've found to do this is to cycle through every control and call...
5
by: ameen.abdullah | last post by:
Hi Guys, I have a textbox in windows form that should only accept alphabets, numbers, spaces and underscore. If the textbox contains anyother character it should display a msg at the time of...
3
by: TheSteph | last post by:
Hi Experts ! I have a Winform Program in C# / .NET 2.0 I would like to ensure that a value in a TextBox is a valid Int32 when user get out of it (TextBox loose focus)
1
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I've noticed that controls do not raise a Validating event if they are contained in a ToolStripDropDown via a ToolStripControlHost item. Please run the following sample and follow the instructions...
8
by: Peted | last post by:
I have an amazing problem which i think i have no hope of solving Im working with a c# dot net module that is hosted by and runs under a delphi form envrioment. Dont ask me how this insanity has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.