mardi 22 mars 2016

PHP Pattern Validation

I'm having a bit of trouble getting my pattern to validate the string entry correctly. The PHP portion of this assignment is working correctly, so I won't include that here as to make this easier to read. Can someone tell me why this pattern isn't matching what I'm trying to do?

This pattern has these validation requirements:

  1. Should first have 3-6 lowercase letters
  2. This is immediately followed by either a hyphen or a space
  3. Followed by 1-3 digits

    $codecheck = '/^([[:lower:]]{3,6}-)|([[:lower:]]{3,6} ?)\d{1,3}$/';
    
    

Currently this catches most of the requirements, but it only seems to validate the minimum character requirements - and doesn't return false when more than 6 or 3 characters (respectively) are entered.

Thanks in advance for any assistance!

Aucun commentaire:

Enregistrer un commentaire