<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Regular Expression Tester</title> </head> <body> <form id="form1" runat="server"> <div> Web Site URL:<br /> <asp:TextBox ID="txtUrl" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="regUrl" runat="server" ControlToValidate="txtUrl" ValidationExpression="^((http|https)://)?([\w-]+\.)+[\w]+(/[\w- ./?]*)?$" Text="Enter a valid URL" /> <asp:Button ID="btnSubmit" Text="Click this to test validation" runat="server" /> </div> </form> </body> </html>