Browse Source

utf8 alpha and alphanum

develop
sheychen 1 year ago
parent
commit
017fc2f1fc
1 changed files with 11 additions and 11 deletions
  1. 11
    11
      src/Input.php

+ 11
- 11
src/Input.php View File

@@ -113,7 +113,7 @@ class Input extends Element{
if(!empty($data)){
if(isset($this->data['phone']) && $this->data['phone'] == true && !preg_match("#^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$#", $data))
return 'incorrect';
if(isset($this->data['number']) && $this->data['number'] == true && !ctype_digit($data))
return 'non numérique';

@@ -129,28 +129,28 @@ class Input extends Element{
}
if(isset($this->data['min']) && $data < $this->data['min'])
return 'trop petit';
if(isset($this->data['max']) && $data > $this->data['max'])
return 'trop grand';
if(isset($this->data['email']) && $this->data['email'] == true && !filter_var($data, FILTER_VALIDATE_EMAIL))
return 'incorrect';
if(isset($this->data['minlength']) && strlen($data) < $this->data['minlength'])
return 'trop court';
if(isset($this->data['maxlength']) && strlen($data) > $this->data['maxlength'])
return 'trop long';
if(isset($this->data['alpha']) && !preg_match('#^[\p{L}'.$this->data['alpha'].']*$#', $data))
if(isset($this->data['alpha']) && !preg_match('#^[\p{L}\p{M}'.$this->data['alpha'].']*$#', $data))
return 'non alphabétique';
if(isset($this->data['alphanum']) && !preg_match('#^[\p{L}\p{N}'.$this->data['alphanum'].']*$#', $data))
if(isset($this->data['alphanum']) && !preg_match('#^[\p{L}\p{M}\p{N}'.$this->data['alphanum'].']*$#', $data))
return 'non alphanumérique';
if(isset($this->data['regex']) && !preg_match('#'.$this->data['regex'].'#', $data))
return 'incorrect';
}
return $parent;
}

Loading…
Cancel
Save