?
Solved

Regular expression validation for a non-required 5 numeric digit only field

Posted on 2009-04-15
3
Medium Priority
?
671 Views
Last Modified: 2012-05-06
I am looking to create a data validation rule using regular expressions that will be for a non-required 5 numeric digit only field.  I don't want the field to be required, but if the user enters data in the field, it should be exactly 5 numeric digits (zero through nine) in length.  Thanks!
0
Comment
Question by:dstjohnjr
3 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 2000 total points
ID: 24153097
This Regex should do the job:
(^$|^[0-9]{5}$)
0
 
LVL 13

Expert Comment

by:numberkruncher
ID: 24153416
You could use the following which is slightly simpler:
^(\d{5})?$

Open in new window

0
 

Author Closing Comment

by:dstjohnjr
ID: 31570741
Worked great!  Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question