30 lines
903 B
JavaScript
30 lines
903 B
JavaScript
|
$(document).ready(function() {
|
||
|
setTextAreaLimit();
|
||
|
|
||
|
function setTextAreaLimit() {
|
||
|
$.fn.extend({
|
||
|
limiter: function(limit, elem) {
|
||
|
$('textarea').on("keyup focus show", function() {
|
||
|
setCount(this, elem);
|
||
|
});
|
||
|
|
||
|
function setCount(src, elem) {
|
||
|
if(src != undefined) {
|
||
|
var chars = src.value.length;
|
||
|
if (chars > limit) {
|
||
|
src.value = src.value.substr(0, limit);
|
||
|
chars = limit;
|
||
|
}
|
||
|
elem.html(limit - chars);
|
||
|
}
|
||
|
}
|
||
|
setCount($(this)[0], elem);
|
||
|
}
|
||
|
});
|
||
|
var elem = $(".chars span");
|
||
|
$('textarea').limiter(1000, elem);
|
||
|
//$('input').limiter(1000, elem);
|
||
|
//$('.Question-1').addClass('active');
|
||
|
}
|
||
|
|
||
|
});
|