Geeks With Blogs

News


Rodney Vinyard - .NET & SQL Developer When all is said and done, more will be said than done

Here is an example of Asp.NET Web page - "complete" zip code text box

1) regex for xxx -> ="^(\d{5}|\d{5}\-\d{4})"   

2) zip code text box with

   a) regex  RegularExpressionValidator   

   b) RequiredFieldValidator               

<asp:TextBox ID="txtZip" runat="server" MaxLength="10"  Width="100px" ></asp:TextBox>

                            <asp:RegularExpressionValidator

                                ID="RequiredFieldValidatorZip"

                              ControlToValidate="txtZip"

                              ValidationExpression="^(\d{5}|\d{5}\-\d{4})$"

                              ErrorMessage="Zip code must be numeric nnnnn or nnnnn-nnnn."

                              Display="dynamic"

                              RunAt="server"></asp:RegularExpressionValidator>

                               <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Zip is a required field!" ControlToValidate="txtZip"></asp:RequiredFieldValidator>

 

Posted on Wednesday, September 24, 2008 2:40 PM regex - regular expressions | Back to top


Comments on this post: regex zip code 5 or 9 digits for "complete" ASP.NET zip code text box

# re: regex zip code 5 or 9 digits for "complete" ASP.NET zip code text box
Requesting Gravatar...
Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.
Left by synthetic urine on Dec 20, 2010 3:03 AM

# sonia
Requesting Gravatar...
Thanks for posting this. i really had good time reading this.
Left by flower delivery mexico on Apr 12, 2011 11:40 PM

# re: regex zip code 5 or 9 digits for "complete" ASP.NET zip code text box
Requesting Gravatar...
Thanks for the great post, was a really interesting psot.
Left by canvas print on Jul 06, 2011 4:26 AM

# re: regex zip code 5 or 9 digits for "complete" ASP.NET zip code text box
Requesting Gravatar...
Admiring the commitment you put into your blog and in depth information you provide. It's awesome to come across a blog every once in a while that isn't the same old rehashed material. Fantastic read! I've saved your site and I'm adding your RSS feeds to my Google account.
Left by Love Quotes on Aug 17, 2011 12:46 PM

# re: regex zip code 5 or 9 digits for "complete" ASP.NET zip code text box
Requesting Gravatar...
Thank you for this!!
Left by Anthony Smith on Jun 21, 2012 12:53 PM

# re: regex zip code 5 or 9 digits for "complete" ASP.NET zip code text box
Requesting Gravatar...
very userful,thanks a lot
Left by Jordan Shoes on Mar 02, 2013 1:34 AM

Your comment:
 (will show your gravatar)


Copyright © Rodney Vinyard | Powered by: GeeksWithBlogs.net