function Validate() { $this->validated = true; $this->validationErrorText = ''; $result = true; $message = ''; $mod = $this->form_ptr->module_ptr; if ($this->Value !== false && !email_validator::is_email($this->Value)) { return array($this->validated, $this->validationErrorText); } }
function Validate() { $this->validated = true; $this->validationErrorText = ''; $mod = $this->form_ptr->module_ptr; switch ($this->ValidationType) { case 'email': if ($this->Value !== false && !email_validator::is_email($this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_an_email', $this->Name); } break; } return array($this->validated, $this->validationErrorText); }
function validateEmailAddr($email) { $mod = $this->form_ptr->module_ptr; $ret = true; $message = ''; if (strpos($email, ',') !== false) { $ta = explode(',', $email); } else { $ta = array($email); } foreach ($ta as $to) { // if (! preg_match(($mod->GetPreference('relaxed_email_regex','0')==0?$mod->email_regex:$mod->email_regex_relaxed), $to)) if (!email_validator::is_email($to)) { $ret = false; $message .= $mod->Lang('not_valid_email', $to); } } return array($ret, $message); }
function Validate() { $this->validated = true; $this->validationErrorText = ''; $mod = $this->form_ptr->module_ptr; switch ($this->ValidationType) { case 'none': break; case 'numeric': if ($this->Value !== false) { $this->Value = trim($this->Value); } if ($this->Value !== false && !preg_match("/^([\\d\\.\\,])+\$/i", $this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_a_number', $this->Name); } break; case 'integer': if ($this->Value !== false) { $this->Value = trim($this->Value); } if ($this->Value !== false && !preg_match("/^([\\d])+\$/i", $this->Value) || intval($this->Value) != $this->Value) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_an_integer', $this->Name); } break; case 'email': if ($this->Value !== false) { $this->Value = trim($this->Value); } if ($this->Value !== false && !email_validator::is_email($this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_an_email', $this->Name); } break; case 'usphone': if ($this->Value !== false) { $this->Value = trim($this->Value); } if ($this->Value !== false && !preg_match('/^([0-9][\\s\\.-]?)?(\\(?[0-9]{3}\\)?|[0-9]{3})[\\s\\.-]?([0-9]{3}[\\s\\.-]?[0-9]{4}|[a-zA-Z0-9]{7})(\\s?(x|ext|ext.)\\s?[a-zA-Z0-9]+)?$/', $this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_a_phone', $this->Name); } break; case 'regex_match': if ($this->Value !== false && !preg_match($this->GetOption('regex', '/.*/'), $this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_valid', $this->Name); } break; case 'regex_nomatch': if ($this->Value !== false && preg_match($this->GetOption('regex', '/.*/'), $this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_valid', $this->Name); } break; } if ($this->GetOption('length', 0) > 0 && strlen($this->Value) > $this->GetOption('length', 0)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_no_longer', $this->GetOption('length', 0)); } return array($this->validated, $this->validationErrorText); }
function Validate() { $this->validated = true; $this->validationErrorText = ''; $mod = $this->form_ptr->module_ptr; if (!is_array($this->Value)) { $this->Value = array($this->Value); } foreach ($this->Value as $thisVal) { switch ($this->ValidationType) { case 'none': break; case 'numeric': if ($thisVal !== false && !preg_match("/^([\\d\\.\\,])+\$/i", $thisVal)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_a_number', $this->Name); } break; case 'integer': if ($thisVal !== false && !preg_match("/^([\\d])+\$/i", $thisVal) || intval($thisVal) != $thisVal) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_an_integer', $this->Name); } break; case 'email': if ($thisVal !== false && !email_validator::is_email($this->Value)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_an_email', $this->Name); } break; case 'regex_match': if ($thisVal !== false && !preg_match($this->GetOption('regex', '/.*/'), $thisVal)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_valid', $this->Name); } break; case 'regex_nomatch': if ($thisVal !== false && preg_match($this->GetOption('regex', '/.*/'), $thisVal)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_valid', $this->Name); } break; } if ($this->GetOption('length', 0) > 0 && strlen($thisVal) > $this->GetOption('length', 0)) { $this->validated = false; $this->validationErrorText = $mod->Lang('please_enter_no_longer', $this->GetOption('length', 0)); } } return array($this->validated, $this->validationErrorText); }