Quote Originally Posted by linuxguy2 View Post
Hi, Lat9

I have researched how preg_match works and was able to do some matches in test files but I'm totally lost on how to properly implement it in Zencart..
Tried this but I know there needs to be more code involved.
I'm looking for a way to limit the company name to only alphanumeric Characters with the appropriate warning if the rule is not followed.
Here's what I tried in includes/modules/clone_classic/create_account.php around line 130 but no joy.

Thank You for Your time.

Code:
if (ACCOUNT_COMPANY == 'true') {
    if ((int)ENTRY_COMPANY_MIN_LENGTH > 0 && strlen($company) < ENTRY_COMPANY_MIN_LENGTH) {
     ////// ADDED 02-04-2020
      if (preg_match('/^/[A-Za-z0-9]$/', $company)); {
      //////////
    
      $error = true;
      $messageStack->add('create_account', ENTRY_COMPANY_ERROR);
    
    ////
        }
    ////
    
    }
  }
Try changing that to
Code:
if (ACCOUNT_COMPANY == 'true') {
    if (((int)ENTRY_COMPANY_MIN_LENGTH > 0 && strlen($company) < ENTRY_COMPANY_MIN_LENGTH) || !preg_match('/^/[A-Za-z0-9]$/', $company)) {
      $error = true;
      $messageStack->add('create_account', ENTRY_COMPANY_ERROR);
    }
}