Form still being submitted despite being invalid

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFyayBQYXJ0ZXI=?=, Jul 25, 2005.

  1. I have a GridView control which contains a number of textbox controls. Each
    textbox, has 2 validators assigned to it; a required field and a compare
    validator (data type integer compare). These validators have their validation
    group set the same.

    If I enter an invalid value into a textbox, the CompareValidator's message
    appears (*) when the textbox loses focus. However, if then submit the form,
    it submits fine!!

    A validation summary control should appear displaying a message telling the
    user what the problem is.

    I would post the form's source but it's a very complicated form and it would
    be too big to post. Funnily enough, if I copy just the gridview control and
    the validators, etc from the page and put them in a test page, the validation
    works fine :(

    Are there any common things to check?
    =?Utf-8?B?TWFyayBQYXJ0ZXI=?=, Jul 25, 2005
    #1
    1. Advertising

  2. You ought to set ValidationGroup for each TextBox control and for Button
    WebControl too.


    --
    C# Dev


    "Mark Parter" wrote:

    > I have a GridView control which contains a number of textbox controls. Each
    > textbox, has 2 validators assigned to it; a required field and a compare
    > validator (data type integer compare). These validators have their validation
    > group set the same.
    >
    > If I enter an invalid value into a textbox, the CompareValidator's message
    > appears (*) when the textbox loses focus. However, if then submit the form,
    > it submits fine!!
    >
    > A validation summary control should appear displaying a message telling the
    > user what the problem is.
    >
    > I would post the form's source but it's a very complicated form and it would
    > be too big to post. Funnily enough, if I copy just the gridview control and
    > the validators, etc from the page and put them in a test page, the validation
    > works fine :(
    >
    > Are there any common things to check?
    =?Utf-8?B?SmFjZWsgU3Rhd2lja2k=?=, Jul 25, 2005
    #2
    1. Advertising

  3. I've just figured it out. I'm appending another client-side onclick event to
    the form's button and it appears to be affecting the validation.

    "Jacek Stawicki" wrote:

    > You ought to set ValidationGroup for each TextBox control and for Button
    > WebControl too.
    >
    >
    > --
    > C# Dev
    >
    >
    > "Mark Parter" wrote:
    >
    > > I have a GridView control which contains a number of textbox controls. Each
    > > textbox, has 2 validators assigned to it; a required field and a compare
    > > validator (data type integer compare). These validators have their validation
    > > group set the same.
    > >
    > > If I enter an invalid value into a textbox, the CompareValidator's message
    > > appears (*) when the textbox loses focus. However, if then submit the form,
    > > it submits fine!!
    > >
    > > A validation summary control should appear displaying a message telling the
    > > user what the problem is.
    > >
    > > I would post the form's source but it's a very complicated form and it would
    > > be too big to post. Funnily enough, if I copy just the gridview control and
    > > the validators, etc from the page and put them in a test page, the validation
    > > works fine :(
    > >
    > > Are there any common things to check?
    =?Utf-8?B?TWFyayBQYXJ0ZXI=?=, Jul 25, 2005
    #3
  4. Have you set the validation Display to none.

    If so, you'll have to set:

    if(Page.IsValid)
    {

    }

    In your method you want to use these on.
    That will prevent the page from displaying.


    "Mark Parter" <> wrote in message
    news:...
    >I have a GridView control which contains a number of textbox controls. Each
    > textbox, has 2 validators assigned to it; a required field and a compare
    > validator (data type integer compare). These validators have their
    > validation
    > group set the same.
    >
    > If I enter an invalid value into a textbox, the CompareValidator's message
    > appears (*) when the textbox loses focus. However, if then submit the
    > form,
    > it submits fine!!
    >
    > A validation summary control should appear displaying a message telling
    > the
    > user what the problem is.
    >
    > I would post the form's source but it's a very complicated form and it
    > would
    > be too big to post. Funnily enough, if I copy just the gridview control
    > and
    > the validators, etc from the page and put them in a test page, the
    > validation
    > works fine :(
    >
    > Are there any common things to check?
    Grant Merwitz, Jul 25, 2005
    #4
  5. =?Utf-8?B?TWFyayBQYXJ0ZXI=?=

    dd Guest

    looks to me that script versions are different.
    "Mark Parter" <> wrote in message
    news:...
    > I have a GridView control which contains a number of textbox controls.

    Each
    > textbox, has 2 validators assigned to it; a required field and a compare
    > validator (data type integer compare). These validators have their

    validation
    > group set the same.
    >
    > If I enter an invalid value into a textbox, the CompareValidator's message
    > appears (*) when the textbox loses focus. However, if then submit the

    form,
    > it submits fine!!
    >
    > A validation summary control should appear displaying a message telling

    the
    > user what the problem is.
    >
    > I would post the form's source but it's a very complicated form and it

    would
    > be too big to post. Funnily enough, if I copy just the gridview control

    and
    > the validators, etc from the page and put them in a test page, the

    validation
    > works fine :(
    >
    > Are there any common things to check?
    dd, Jul 25, 2005
    #5
    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. Eric Shin

    Form submitted

    Eric Shin, Jan 12, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    457
    Martha[MSFT]
    Jan 12, 2004
  2. SWu
    Replies:
    0
    Views:
    565
  3. =?Utf-8?B?U2FtIEphY2tzb24=?=

    Form posting despite validation errors

    =?Utf-8?B?U2FtIEphY2tzb24=?=, Apr 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    365
    =?Utf-8?B?U2FtIEphY2tzb24=?=
    Apr 5, 2004
  4. Robocop
    Replies:
    5
    Views:
    309
    Robocop
    Oct 17, 2008
  5. yawnmoth
    Replies:
    3
    Views:
    112
Loading...

Share This Page