diff --git a/forms/CustomRequiredFields.php b/forms/CustomRequiredFields.php index 2d4c26dff..971565e5e 100755 --- a/forms/CustomRequiredFields.php +++ b/forms/CustomRequiredFields.php @@ -123,7 +123,7 @@ class CustomRequiredFields extends RequiredFields{ eval($fieldName['php']); }else if($formField) { // if an error is found, the form is returned. - if(!$data[$fieldName] || preg_match('/^\s*$/', $data[$fieldName])) { + if(!strlen($data[$fieldName]) || preg_match('/^\s*$/', $data[$fieldName])) { $this->validationError( $fieldName, sprintf(_t('Form.FIELDISREQUIRED', "%s is required."), diff --git a/forms/RequiredFields.php b/forms/RequiredFields.php index 5e8149996..3d9b1b7aa 100755 --- a/forms/RequiredFields.php +++ b/forms/RequiredFields.php @@ -99,8 +99,8 @@ JS; } if($this->required) { foreach($this->required as $fieldName) { - $formField = $fields->dataFieldByName($fieldName); - if($formField && !$data[$fieldName]) { + $formField = $fields->dataFieldByName($fieldName); + if($formField && !strlen($data[$fieldName])) { $errorMessage = sprintf(_t('Form.FIELDISREQUIRED', '%s is required').'.', strip_tags('"' . ($formField->Title() ? $formField->Title() : $fieldName) . '"')); if($msg = $formField->getCustomValidationMessage()) { $errorMessage = $msg; diff --git a/forms/Validator.php b/forms/Validator.php index 9bcd66cd2..d7d1f605e 100755 --- a/forms/Validator.php +++ b/forms/Validator.php @@ -167,7 +167,7 @@ abstract class Validator extends Object { } function requireField($fieldName, $data) { - if(!$data[$fieldName]) $this->validationError($fieldName, "$fieldName is required.", "required"); + if(!strlen($data[$fieldName])) $this->validationError($fieldName, "$fieldName is required.", "required"); } function includeJavascriptValidation() {