troubleshooting Question

zip code validation

Avatar of nmarano
nmarano asked on
2 Comments2 Solutions194 ViewsLast Modified:

I have this validation on a ColdFusion form.  If the user doesn't enter anything, the pop-up works.  If the user enters one digit, the form gets processed.  Is there a way for me to check for a minimum of 5 digits?

Any help would be appreciated

function _CF_checkzip(object_value, required)
      //trim whitespace before we validate
    object_value = object_value.replace(/^\s+/,'').replace(/\s+$/,'');

    if( required )
        if( object_value.length == 5 )
            return false;
        if( object_value.length == 5 )
            return true;

      return _CF_checkregex(object_value, /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/, required);
Ken Butters

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros