Form still being submitted despite being invalid

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?
 
G

Guest

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

Guest

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.
 
G

Grant Merwitz

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.
 

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top