How to call RequiredFieldValidator on client before postback

Posted by Si on Stack Overflow See other posts from Stack Overflow or by Si
Published on 2010-03-22T00:26:42Z Indexed on 2010/03/22 0:31 UTC
Read the original article Hit count: 607

Filed under:
|

I've inherited some code which breaks a page up into tabs using divs. On the first page there are many required field and regex validators. The problem is a user can switch to another tab, trigger a postback and fail the validators on the first page, leaving things in a mess.

What I want to be able to do is perform the validation on the first page as a user selects another tab, thus preventing them from moving to a new tab until the first page is valid.

<ul>                        
     <li><a href="#tab1">Tab 1</a> </li>
     <li><a href="#tab2" onclick="return isValid();">Tab 2</a></li> 
     <li><a href="#tab3" onclick="return isValid();">Tab 3</a></li> 
</ul>

Where isValid needs to fire off the validators.

Thanks!

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about validation