Form still being submitted despite being invalid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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.
 
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.
 
Back
Top