views:

252

answers:

2

I'm looking for a way to trigger ASP.NET validator controls upon a page loading.

I have a ValidationSummary and a series of RequiredFieldValidators and CheckBoxListValidators on my page all assigned to the same ValidationGroup. When the button that is tied to the validation group is clicked the page is properly validated.

I've attempted to use JavaScript on the client side using both the function ValidatorValidate() and Page_ClientValidate(). When I attempt to use both of these items I get an "Object Expected" error in IE8. What exactly am I supposed to pass into these functions? The ValidationGroup or each individual control I want to validate? I've looked at various tutorials and blog posts and it all seems so simple, yet I'm left scratching my head trying to figure out these functions.

A: 

You need to do it in the onload event of the HTML.

Option 1

<html onload="Page_ClientValidate()">

Option 2, jQuery

<script language="JavaScript">
    jQuery(function() {
        Page_ClientValidate();
    }
</script>
Jason Jong
A: 

Untested, but in theory in your Page_Load you could call something like:

Page.Validate()
Nicholas H