Answer the question
In order to leave comments, you need to log in
Different validation values on client and server in Yii?
Hello comrades!!
Faced such a problem, namely with different validation values on the client and on the server in YII.
The essence of the problem is as follows:
1. There is a validation rule
array('desc', 'length', 'encoding' => 'utf-8', 'max' => 150, 'tooLong' => 'Comment must not exceed 150 characters' ) 2. In
the
textarea for this attribute, I enter two characters per line:
!d
!d
!d
, etc.
passes, but does not pass on the server
4. I know that the problem is in the line break character, namely 150 characters with line breaks on the client are equal to 200 characters on the server, that is, the line break character on the client is 1 character, on the server 2
5. unix / windows there is no difference on which os server , the problem is both there and there
5. How to be?
Answer the question
In order to leave comments, you need to log in
Evgeny Dozhdikov :
if(function_exists('mb_strlen') && $this->encoding!==false)
$length=mb_strlen($value, $this->encoding ? $this->encoding : Yii::app()->charset);
else
$length=strlen($value);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question