From: colemanw Date: Mon, 26 Jun 2017 21:09:32 +0000 (-0400) Subject: Better numeric check X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d98b091cc525fc09d01b22f61f3911539af6c118;p=civicrm-core.git Better numeric check --- diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 6ab31472ac..c6c17e5efb 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -95,14 +95,9 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $errors['extends'] = ts('If you plan on using this price set for membership signup and renewal, you can not also use it for Events or Contributions. However, a membership price set may include additional fields for non-membership options that require an additional fee (e.g. magazine subscription).'); } } - //checks the given price set doesnot start with digit - $title = $fields['title']; - if ($title) { - // gives the ascii value - $asciiValue = ord($title{0}); - if ($asciiValue >= 48 && $asciiValue <= 57) { - $errors['title'] = ts("Name cannot not start with a digit"); - } + // Checks the given price set does not start with a digit + if (strlen($fields['title']) && is_numeric($fields['title'][0])) { + $errors['title'] = ts("Name cannot not start with a digit"); } return empty($errors) ? TRUE : $errors; }