473,396 Members | 2,029 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,396 software developers and data experts.

Validating a control - contains only numbers and not null

Hi there,

I want to ensure that a text box contains a number and is not blank. I'm
using the regular expression validator to do this with this line

ValidationExpression="[0-9]+"

This expression works when I enter input which is not numeric but it will
not work when I leave the field blank. I've tried quite a few variations on
the regular expression but i'm getting nowhere. How can I check for a
non-null numeric value??

Thanks

Steve
Nov 21 '05 #1
4 6897
Hi,

Dim regNum As New
System.Text.RegularExpressions.Regex("^(\d|-)?(\d|,)*\.?\d*$")

MessageBox.Show(regNum.IsMatch(TextBox1.Text).ToSt ring)

Ken

----------------------

"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:qM************@newsfe1-gui.ntli.net...
Hi there,

I want to ensure that a text box contains a number and is not blank. I'm
using the regular expression validator to do this with this line

ValidationExpression="[0-9]+"

This expression works when I enter input which is not numeric but it will
not work when I leave the field blank. I've tried quite a few variations on
the regular expression but i'm getting nowhere. How can I check for a
non-null numeric value??

Thanks

Steve

Nov 21 '05 #2
Hi,

Dim regNum As New
System.Text.RegularExpressions.Regex("^(\d|-)?(\d|,)*\.?\d*$")

MessageBox.Show(regNum.IsMatch(TextBox1.Text).ToSt ring)

Ken

----------------------

"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:qM************@newsfe1-gui.ntli.net...
Hi there,

I want to ensure that a text box contains a number and is not blank. I'm
using the regular expression validator to do this with this line

ValidationExpression="[0-9]+"

This expression works when I enter input which is not numeric but it will
not work when I leave the field blank. I've tried quite a few variations on
the regular expression but i'm getting nowhere. How can I check for a
non-null numeric value??

Thanks

Steve

Nov 21 '05 #3
Thanks for the help :)

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Dim regNum As New
System.Text.RegularExpressions.Regex("^(\d|-)?(\d|,)*\.?\d*$")

MessageBox.Show(regNum.IsMatch(TextBox1.Text).ToSt ring)

Ken

----------------------

"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:qM************@newsfe1-gui.ntli.net...
Hi there,

I want to ensure that a text box contains a number and is not blank. I'm
using the regular expression validator to do this with this line

ValidationExpression="[0-9]+"

This expression works when I enter input which is not numeric but it will
not work when I leave the field blank. I've tried quite a few variations on the regular expression but i'm getting nowhere. How can I check for a
non-null numeric value??

Thanks

Steve

Nov 21 '05 #4
Thanks for the help :)

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

Dim regNum As New
System.Text.RegularExpressions.Regex("^(\d|-)?(\d|,)*\.?\d*$")

MessageBox.Show(regNum.IsMatch(TextBox1.Text).ToSt ring)

Ken

----------------------

"Stephen Adam" <st**********@ntlworld.com> wrote in message
news:qM************@newsfe1-gui.ntli.net...
Hi there,

I want to ensure that a text box contains a number and is not blank. I'm
using the regular expression validator to do this with this line

ValidationExpression="[0-9]+"

This expression works when I enter input which is not numeric but it will
not work when I leave the field blank. I've tried quite a few variations on the regular expression but i'm getting nowhere. How can I check for a
non-null numeric value??

Thanks

Steve

Nov 21 '05 #5

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

Similar topics

1
by: Deano | last post by:
If I need my Excel file to contain only 3 columns before I import it into Excel using VBA, how could I check that this is so? Also another check that I might like to perform is ensuring that a...
0
by: Chris Millar | last post by:
I have a user control that i wish to extend to change the date when the user selects the numeric up down button. The code explains itself, hope someone can help. any ideas appreaciated.. ...
7
by: ani | last post by:
I have two submit buttons in my form which need to validate two different controls on the page . How do I validate portions of the asp.net page. The two submit buttons should validate their...
2
by: Andrea | last post by:
If anyone has a simple routine to validate that text entered in a text box control contains only numbers (zip code) or only alpha characters (name), can you please send me? I'm new to this, and...
0
by: Stephen Adam | last post by:
Hi there, I want to ensure that a text box contains a number and is not blank. I'm using the regular expression validator to do this with this line ValidationExpression="+" This expression...
5
by: norton | last post by:
Hi All, I am writing a simple win form which contains a button, when user click the button i want to validate all the other textbox and see if there is anything goes wrong may i know how...
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: mehdi | last post by:
Hi, Consider a dialog that contains some control. You know, the form is validated when every single control in the form is validated successfully. However, if one control tries to cancel the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.