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

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -

php - Autoloader issue not returning Class -