2016-07-29 08:57:28 -05:00
|
|
|
$(document).ready(function() {
|
2016-08-09 11:36:52 -05:00
|
|
|
setTextAreaLimit();
|
2016-07-29 08:57:28 -05:00
|
|
|
|
2016-08-09 11:36:52 -05:00
|
|
|
function setTextAreaLimit() {
|
|
|
|
$.fn.extend({
|
|
|
|
limiter: function(limit, elem) {
|
|
|
|
$('textarea').on("keyup focus show", function() {
|
|
|
|
setCount(this, elem);
|
|
|
|
});
|
2016-07-29 08:57:28 -05:00
|
|
|
|
2016-08-09 11:36:52 -05:00
|
|
|
function setCount(src, elem) {
|
|
|
|
if(src !== undefined) {
|
|
|
|
var chars = src.value.length;
|
|
|
|
if (chars > limit) {
|
|
|
|
src.value = src.value.substr(0, limit);
|
|
|
|
chars = limit;
|
2016-07-29 08:57:28 -05:00
|
|
|
}
|
2016-08-09 11:36:52 -05:00
|
|
|
elem.html(limit - chars);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setCount($(this)[0], elem);
|
|
|
|
}
|
|
|
|
});
|
2016-07-29 08:57:28 -05:00
|
|
|
|
2016-08-09 11:36:52 -05:00
|
|
|
var elem = $(".chars span");
|
|
|
|
$('textarea').limiter(1000, elem);
|
|
|
|
}
|
|
|
|
});
|