<%@ Page Language="VB" ClientTarget="downlevel" %> <SCRIPT LANGUAGE="VB" RUNAT="SERVER"> Sub btnSubmit_OnClick(Obj as Object, E as EventArgs) 'Determine if the form entries were valid If Page.IsValid then 'This is the point where we want to handle the form. 'Once we've "handled" the form we'll redirect the user to 'the ThankYou.aspx page. 'You could do a number of things here, to "handle" the form. 'Perhaps you want to send an email to someone, or update/insert a 'record in a database. In any case, this is the place where you would 'do that... Page.Navigate("ThankYou.aspx?Name=" & txtName.Text) 'Redirect the user End If End Sub </SCRIPT> <HTML> <BODY> Enter the following information: <form method="post" action="validation.aspx" runat="server"> <TABLE BORDER=0> <!--Name textbox and validation--> <TR><TD ALIGN=RIGHT> <B>Name:</B> </TD><TD> <asp:Textbox id="txtName" runat="server"/> </TD><TD> <asp:RequiredFieldValidator runat="server" id="reqName" ControlToValidate="txtName" ErrorMessage = "You must provide your name!" display="Dynamic" /> </TD></TR> <!--Age textbox and validation--> <asp:TextBox id="minAge" text="5" runat="server" visible="False" /> <asp:TextBox id="maxAge" text="120" runat="server" visible="False" /> <TR><TD ALIGN=RIGHT> <B>Age:</B> </TD><TD> <input type="text" id="txtAge" runat="server"/> </TD><TD> <asp:RequiredFieldValidator runat="server" id="reqAge" ControlToValidate="txtAge" ErrorMessage = "You must provide your age!" display="Dynamic" /> <asp:RegularExpressionValidator runat="server" id="regexpAge" ControlToValidate="txtAge" ValidationExpression="^\d{1,3}$" ErrorMessage = "Your age must be one to three digits." Display="Dynamic" /> <asp:RangeValidator runat="server" Type="Integer" id="rangeAge" ControlToValidate="txtAge" MinimumControl="minAge" MaximumControl="maxAge" ErrorMessage = "Your age must be between 5 and 120." Display="Dynamic" /> </TD></TR> <!--SSN textbox and validation--> <TR><TD ALIGN=RIGHT> <B>Social Security Number:</B> </TD><TD> <input type="text" id="txtSSN" runat="server"/> </TD><TD> <asp:RequiredFieldValidator runat="server" id="reqSSN" ControlToValidate="txtSSN" ErrorMessage = "You must provide your Social Security Number." display="Dynamic" /> <asp:RegularExpressionValidator runat="server" id="regexpSSN" ControlToValidate="txtSSN" ValidationExpression="^\d{3}\-\d{2}\-\d{4}$" ErrorMessage = "Your Social Seucrity Number must be in the format: XXX-XX-XXXX" Display="Dynamic" /> </TD></TR> <TR><TD COLSPAN=3 ALIGN=CENTER> <asp:button type="submit" name="btnSubmit" onclick="btnSubmit_OnClick" text="Submit Form!" runat="server"/> </TD></TR> </TABLE> </form> </BODY> </HTML>