Different maxlength validation of textarea with newlines in Chrome and Firefox Different maxlength validation of textarea with newlines in Chrome and Firefox google-chrome google-chrome

Different maxlength validation of textarea with newlines in Chrome and Firefox


I didnt find any solution to make the maxlength atribute to work the same way in all browsers, and I think is because its relative new. So I decided to go for javascript.

Googling a little I found this jQuery Max Length plugin that works great just adding a few lines. Is available under the MIT licence. And counts newlines as it should be (2 characters)

It has some parameters to set the maxlength, feedback text, background change when full, between others. The website has very good documentation and a lot of examples.

Example

It's highly customisableā€Ž, for example here is mine

Own

This is the only code I used plus some css.

<script type="text/javascript" src="jquery.plugin.js"></script><script type="text/javascript" src="jquery.maxlength.js"></script><script>    $(function() {        $('.t_tresc').maxlength({            showFeedback: true,            feedbackText: '{c} / {m} max.',             overflowText: '{c} / {m} max!',             feedbackTarget: '#targetFeedback$name',            max: $max_length,            truncate: false,            onFull: null        });     });</script>