Link to home
Start Free TrialLog in
Avatar of nmarano
nmarano

asked on

zip code validation

Experts-

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
Thanks
Nick

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;
        }
    }
      else{
        if( object_value.length == 5 )
        {
            return true;
        }
    }

      return _CF_checkregex(object_value, /^([0-9]{5})(?:[-\s]*([0-9]{4}))?$/, required);
}
ASKER CERTIFIED SOLUTION
Avatar of Ken Butters
Ken Butters
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial