<script>
window.onload = function () {
var number = document.getElementById('number');
var text = document.getElementById('text');
var btn = document.getElementById('btn');
var m= 140 - text.value.length;
text.onkeyup = function aa() {
m= 140 - text.value.length;
if (m < 0) {
number.style.color = 'red';
}else {
number.style.color = '#999999';
}
number.innerHTML = m;
};
btn.onclick = function () {
if (m==140) {
alert('你输入的内容为空!请重新输入');
text.focus();
} else if (m < 0) {
alert('你的字数太多,不能发送!');
text.focus();
} else {
alert('发送成功,正在跳转.....');
}
};
aa()
}
</script>