A valid 5 digit zip code : Regular Expression Validator « Validation by Control « ASP.Net

A valid 5 digit zip code

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:TextBox ID="txtValue" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Submit" />&nbsp;
        ID="RegularExpressionValidator1" runat="server" 
        ValidationExpression="\d{5}(-\d{4})?">Please enter a valid 5 digit zip code</asp:RegularExpressionValidator>


Related examples in the same category

1.Try validation based on Regular Expression in C#
2.Using a RegularExpressionValidator Control to Prevent the Entry of a Special Character (VB.net)
3.Regular expression validator: ^\d{5}$|^\d{5}-\d{4}$ (VB.net)
4.Validate input of US SSN