required field validator code example

Example: asp only trigger specific requiredfieldvalidator

<asp:textbox id="AgeTextBox" 
  runat="Server">
</asp:textbox>

&nbsp;

<asp:requiredfieldvalidator id="RequiredFieldValidator1"
  controltovalidate="AgeTextBox"
  validationgroup="PersonalInfoGroup"
  errormessage="Enter your age."
  runat="Server">
</asp:requiredfieldvalidator>

<br /><br />

<!--When Button1 is clicked, only validation
controls that are a part of PersonalInfoGroup
are validated.-->
<asp:button id="Button1" 
  text="Validate" 
  causesvalidation="true"
  validationgroup="PersonalInfoGroup"
  runat="Server" />