Collin Estes
Collin Estes

Reputation: 5799

Required Field Validator, displaying on initial page load

I have a simple textbox with a required field validation control attached to end and then being displayed in a validation summary at that bottom of the page. Everything works great on it but the validation seems to fire on the page's initial load which obviously sets off the required validation and displays the error message.

How do I set this control to only validate after the form has been submitted?

Upvotes: 2

Views: 7026

Answers (1)

Joel Coehoorn
Joel Coehoorn

Reputation: 416049

It sounds like you have code in your page load like this:

if (!Page.IsValid) { }

What you really want is this:

if (Page.IsPostBack && !Page.IsValid) { }

Upvotes: 3

Related Questions