RegularExpressionValidator.IsValid Returns TRUE!?

Discussion in 'ASP .Net Web Controls' started by Larry Lawhead, Dec 1, 2003.

  1. My problem is that IsValid returns TRUE when, based on Validation
    Expression, result should be FALSE.

    Properties (departing from defaults):
    Enable Client Script: False (Just incase it matters)
    Validation Expression: [0-9\.,]*

    Code Example:

    private void cbxAvailable_CheckedChanged(object sender, System.EventArgs e)
    {
    if(valWeight.IsValid == false)
    {
    valWeight.ErrorMessage = "Use numbers only.";
    tbxProdWeight.Text = "";
    }
    }

    I created a prototype using the same property settings that works just fine.
    Here is the code from that example:

    private void Button2_Click(object sender, System.EventArgs e)
    {
    if(RegularExpressionValidator1.IsValid)
    {
    Label1.Text = TextBox1.Text;
    TextBox1.Text = "";
    }
    else if (RegularExpressionValidator1.IsValid == false)
    {
    Label1.Text = "";
    TextBox1.Text = "";
    }
    }

    I must be overlooking something quit simple here. Any suggestions?

    Thanks!
     
    Larry Lawhead, Dec 1, 2003
    #1
    1. Advertising

  2. Larry Lawhead

    Sink Guest

    This usually happens when the control is being called
    before the validate() function has been called for the
    page and therefore your validator has been evaluated
    as yet.

    Try calling RegularExpressionValidator1.Validate()
    before checking the IsValid property.

    >-----Original Message-----
    >My problem is that IsValid returns TRUE when, based on

    Validation
    >Expression, result should be FALSE.
    >
    >Properties (departing from defaults):
    >Enable Client Script: False (Just incase it matters)
    >Validation Expression: [0-9\.,]*
    >
    >Code Example:
    >
    >private void cbxAvailable_CheckedChanged(object sender,

    System.EventArgs e)
    >{
    > if(valWeight.IsValid == false)
    > {
    > valWeight.ErrorMessage = "Use numbers only.";
    > tbxProdWeight.Text = "";
    > }
    >}
    >
    >I created a prototype using the same property settings

    that works just fine.
    >Here is the code from that example:
    >
    >private void Button2_Click(object sender,

    System.EventArgs e)
    >{
    > if(RegularExpressionValidator1.IsValid)
    > {
    > Label1.Text = TextBox1.Text;
    > TextBox1.Text = "";
    > }
    > else if (RegularExpressionValidator1.IsValid == false)
    > {
    > Label1.Text = "";
    > TextBox1.Text = "";
    > }
    >}
    >
    >I must be overlooking something quit simple here. Any

    suggestions?
    >
    >Thanks!
    >
    >
    >.
    >
     
    Sink, Dec 1, 2003
    #2
    1. Advertising

  3. Thanks, works great!

    "Sink" <> wrote in message
    news:035101c3b846$1c35df60$...
    > This usually happens when the control is being called
    > before the validate() function has been called for the
    > page and therefore your validator has been evaluated
    > as yet.
    >
    > Try calling RegularExpressionValidator1.Validate()
    > before checking the IsValid property.
    >
    > >-----Original Message-----
    > >My problem is that IsValid returns TRUE when, based on

    > Validation
    > >Expression, result should be FALSE.
    > >
    > >Properties (departing from defaults):
    > >Enable Client Script: False (Just incase it matters)
    > >Validation Expression: [0-9\.,]*
    > >
    > >Code Example:
    > >
    > >private void cbxAvailable_CheckedChanged(object sender,

    > System.EventArgs e)
    > >{
    > > if(valWeight.IsValid == false)
    > > {
    > > valWeight.ErrorMessage = "Use numbers only.";
    > > tbxProdWeight.Text = "";
    > > }
    > >}
    > >
    > >I created a prototype using the same property settings

    > that works just fine.
    > >Here is the code from that example:
    > >
    > >private void Button2_Click(object sender,

    > System.EventArgs e)
    > >{
    > > if(RegularExpressionValidator1.IsValid)
    > > {
    > > Label1.Text = TextBox1.Text;
    > > TextBox1.Text = "";
    > > }
    > > else if (RegularExpressionValidator1.IsValid == false)
    > > {
    > > Label1.Text = "";
    > > TextBox1.Text = "";
    > > }
    > >}
    > >
    > >I must be overlooking something quit simple here. Any

    > suggestions?
    > >
    > >Thanks!
    > >
    > >
    > >.
    > >
     
    Larry Lawhead, Dec 1, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Davis
    Replies:
    1
    Views:
    412
    Jon Davis
    Jan 27, 2004
  2. Jon Davis
    Replies:
    3
    Views:
    508
    Jon Davis
    Jan 27, 2004
  3. Jeremy
    Replies:
    2
    Views:
    637
    Jeremy
    Jul 1, 2004
  4. Pierre Quentel

    "0 in [True,False]" returns True

    Pierre Quentel, Dec 12, 2005, in forum: Python
    Replies:
    59
    Views:
    1,077
    Grant Edwards
    Dec 16, 2005
  5. bdb112
    Replies:
    45
    Views:
    1,419
    jazbees
    Apr 29, 2009
Loading...

Share This Page