all input fields with limited chars, am using with jquery function to get proper output if i use keyup it works fine but not applying to all popup wizard in my application if i use keydown it shows incorrect values while typing on input fields
<div>
<input type="text" />
<textarea></textarea><label class="input_label w-100 text-right" style="font-size:11px ;"></label>
</div>
<hr/>
<div>
<input type="text" />
<textarea></textarea><label class="input_label w-100 text-right" style="font-size:11px ;"></label>
</div>
<hr/>
$(document).on('keydown','input[type="text"],textarea ',function(){
tag_name = $(this).prop("tagName")
if(tag_name == 'TEXTAREA'){
limit = 200
limit_warning = 179
$(this).attr('maxlength',200,)
}
else{
limit = 20
limit_warning = 15
$(this).attr('maxlength',20,)
}
this_vall = $(this).val()
length_count = this_vall.length
var text_field = length_count + "/" + limit;
label_tag = $(this).siblings('label')
is_label_exist = label_tag.length
if(is_label_exist <1){
x = ` <label class="input_label w-100 text-right" style="font-size:11px ;">${text_field}</label>`
$(this).parent().append(x)
$(label_tag).text(text_field)
}
else{
$(label_tag).text(text_field)
}