0

I have a registration form. I need to validate zipcode. Validation rules must be integer, Max length not greater than 7.

I had tried validation but it validate zip must be 5. But some countries has 6 or 4 zipcode. Any help would be appreciated.

'zipcode'   => 'required|regex:/^[0-9]{5}(\-[0-9]{4})?$/',
Sarath TS
  • 2,432
  • 6
  • 32
  • 79

1 Answers1

1

If what you want is numeric digits only, at least 3 but no more than 7, you should use

'zipcode'   => 'required|regex:/^[0-9]{3,7}$/'