Javascript javascript字符串长度比较
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2210432/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-22 23:15:05 来源:igfitidea点击:
javascript string length compare
提问by Shah
I want to check the size of the string entered in a text box. what am I missing?
我想检查在文本框中输入的字符串的大小。我错过了什么?
var com = document.getElementById("comment").value;
if(com.lenght <= 100){
alert("good");
} else {
alert("bad");
}
回答by Mark Byers
Try changing lenght to length.
尝试将长度更改为长度。
回答by Marek Karbarz
misspelled lenght- should be length
拼写错误lenght- 应该是length
回答by Sarfraz
Mis-spelling:
拼错:
if(com.lenght <= 100){
use this:
用这个:
if(com.length <= 100){
回答by jpabluz
It is written length not lenght.
写的是长度而不是长度。

