Stop user from typing into input field after certain character limit with PURE JAVASCRIPT -


i have use js. assignment.

this code:

var bio = document.getelementbyid('bio'); var charsleft = document.getelementbyid('charsleft'); bio.onkeypress = function(evt) {     evt = evt || window.event;     var remaining;     var perm = bio.value;     remaining = 139 - bio.value.length;     charsleft.innerhtml = remaining;     if (remaining == 0) {         bio.value = perm;     } } 

it not stop user typing stuff after charsleft 0.

please not mark duplicate!

this pure javascript approach find

you dont need javascript :

<input type="text" name="fieldname" maxlength="100"> 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -