Jsvalidator in CakePHP is incorrectly error-correcting textareas
I'm using the CakePHP Javascript Validator, and everything works just fine EXCEPT validati开发者_开发技巧ng textareas.
The problem isn't that it doesn't validate at all - but it has a problem with:
'rule' => array('between', 20, 500),
This error is triggered if they enter any linebreaks anywhere in the textarea regardless of the total # of characters or even the total # of characters in the first line.
Any thoughts as to 1) why this would happen and 2) how to fix it?
Edit:
The regex is being written in plugins/js_validate/views/helpers/validation.php, and it appears to be generating this:
The regex it's spitting out for validating my textarea field is this: \/^.{4,138}$\/
I assume the problem is the ".", since that is "anything except newlines" or something. What do I replace it with to allow newlines?
Use s
modifier which makes dot metacharacter match all characters, including newlines. In your case expression will look like:
/^.{4,138}$/s
精彩评论