Wednesday 28 October 2015

How to prevent user type in textarea not more than 150 charater

Hello Guys, if you have complex form that make users not typing to much character like in twtitter, i'm sure you have the reason about this but i don't care about your reason here is my demo for you
check this out

Please conside about this see my code bellow which is maxlength is prevent users type more than 150 character, so i choose this to make it simple
 <textarea class="form-control" maxlength="150" name="product_keterangan" required=""></textarea>  

Then i use this js just for count charachter
 var maxLength = 150;  
 $('textarea').keyup(function() {  
  var length = $(this).val().length;  
  var length = maxLength-length;  
  $('#chars').text(length);  
 });  

No comments:

Post a Comment