Validating a control - contains only numbers and not null

  • Thread starter Thread starter Stephen Adam
  • Start date Start date
S

Stephen Adam

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
 
Hi,

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

MessageBox.Show(regNum.IsMatch(TextBox1.Text).ToString)



Ken

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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top