CodeIgniter Forums
maxlength in texture with newline - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: maxlength in texture with newline (/showthread.php?tid=65440)



maxlength in texture with newline - rchiu5hk - 06-12-2016

Dear all,

I have below code for inputting text. If text contains new line, it will have problems in controller php. Can input max desc in front end.
But backend it cannot pass max length validation when there is new line. How to also check in front end which also take into consider the new line.

Code:
<textarea class="form-control" style="vertical-align: top; horizontal-align: left;
                              resize:none;" id="descriptionTextarea" name="descriptionTextarea" rows="4"  required="true"  maxlength="<?php echo DESCLENGTHINNEWPOST;?>"><?php echo set_value('descriptionTextarea'); ?></textarea>


In the controller,

Code:
$content=nl2br(htmlentities($des, ENT_QUOTES, 'UTF-8'));
if(ExceedDescLength($content, DESCLENGTHINNEWPOST)){
      // fall into this
}