【发布时间】:2012-10-29 06:24:02
【问题描述】:
嗨,我正在使用 SMS 面板,我想检查文本区域的长度,现在我正在使用这些代码:
$("#txt").keydown(function () {
var len = $(this).val().length;
$("#lbl").text(len);
if (len <= 70) {
$("#lbl").text("One SMS");
if (confirm("more than one sms are you sure?")) {
$("#lbl").text(len);
}
}
else if (len >= 71 && len <= 133) {
$("#lbl").text("two SMS");
if (confirm("more than two sms are you sure?")) {
$("#lbl").text(len);
}
}
else if (len > 134 && len <= 199) {
$("#lbl").text("three SMS");
alert("more than three sms are you sure?");
}
});
我希望当我将文本粘贴到 textArea 时会显示警报并选择 no cant input anything
感谢您的建议?
【问题讨论】:
-
第一个建议 - 提出可回答的问题。 “不完美”根本不是解释。
-
@zerkms 例如,当我将文本复制到 textarea 时它不起作用。
-
@MilindAnantwar 我不想使用插件
-
我不同意你的代码不应该在这种情况下工作......
标签: jquery