Tell us what you are trying to do?
Limited Characters in a Textfield and 2 textareas in 1 form
If I use only the textareas then its workd fine, but with the textfield it does not.
Is there any documentation that you are following?
(function($) {
$.fn.extend( {
limiter: function(limit, elem) {
$(this).on("keyup focus", function() {
setCount(this, elem);
});
function setCount(src, elem) {
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);
}
});
})(jQuery);
var elem = jQuery("#chars0");
jQuery("textfield[name='post_title']").limiter(10, elem);
var elem1 = jQuery("#chars1");
jQuery("textarea[name='wpcf-korte-omschrijving']").limiter(100, elem1);
var elem2 = jQuery("#chars2");
jQuery("textarea[name='wpcf-omschrijving-project']").limiter(2000, elem2);
<div class="form-group col-md-12">
<label for="%%FORM_ID%%_post_title">[cred_i18n name='post_title-label']Project titel[/cred_i18n]</label>
[cred_field field='post_title' class='form-control' output='bootstrap']
<div>Aantal karakters over: <span id="chars0">10</span></div>
<div class="form-group col-md-12">
<label for="%%FORM_ID%%_korte-omschrijving">[cred_i18n name='korte-omschrijving-label']Korte omschrijving project[/cred_i18n]</label>
[cred_field field='korte-omschrijving' force_type='field' class='form-control' output='bootstrap']
<div>Aantal karakters over: <span id="chars1">100</span></div>
</div>
</div>
<div class="row">
<div class="form-group col-md-12">
<label for="%%FORM_ID%%_omschrijving-project">[cred_i18n name='omschrijving-project-label']Omschrijving project[/cred_i18n]</label>
[cred_field field='omschrijving-project' force_type='field' class='form-control' output='bootstrap']
<div>Aantal karakters over: <span id="chars2">2000</span></div>
</div>
This is the form i'm working on
hidden link
What is the link to your site?
hidden link