2017-08-04 9 views

Antwort

0

Mit JQuery:

$("#inputFieldId").on("input propertychange", function(){ 
    var val = this.value; 
    if(val.length > 15) { 
     this.value = val.substring(0,15); //comment if you don't want to remove the 16th character 
     alert("Maximum 15 characters allowed!"); 
    } 
}); 
0

Sie müssen Ihren Code erwähnen, was Sie gebunden. Wie auch immer, wenn Sie nicht wissen, diesen Code versuchen

<input type="text" onkeypress="myFunction(this)" maxlength="5"> 
<script> 
function myFunction(e) { 
var maxlen= e.maxLength; 
if(e.value.length >= maxlen) 
    alert("Max length is limited to" +maxlen); 
} 
</script> 
1

die Sie interessieren Javascript:

document.getElementById("password").onkeyup = function() { 
 

 
    var text = document.getElementById("password").value 
 

 
    if(text.length> 15){ 
 
     alert("too much text") 
 
    } 
 

 

 
};
<input id="password" type="password" placeholder="password">

1

bereits.

function alrtMsg() { 
 
    var x = document.getElementById("pwd").value; 
 
    if(x.length > 16){ 
 
    \t alert("maximum length is 16"); 
 
    \t document.getElementById("pwd").value = ''; 
 
    } 
 
}
<html> 
 
<body> 
 
<input type="password" id="pwd" onkeyup="alrtMsg()"> 
 

 
</body> 
 
</html>

Verwandte Themen