1.判断文本框的内容
<script>
function ajax_addly() {
var name = document.getElementById(‘name‘);
var password = document.getElementById(‘pw‘);
//alert(name.value);
if (name.value == ‘‘) {
alert(‘请输入账号‘);
return;
}
if (password.value == ‘‘) {
alert(‘请输入密码‘);
return;
}
alert(‘登录成功!‘);
}
<asp:TextBox ID="name" placeholder="账号" runat="server"></asp:TextBox>
<asp:TextBox ID="pw" placeholder="密码" runat="server"></asp:TextBox>
<p>
<input type="button" value="确定" onclick="ajax_addly()" />
</p>
</script>
原文:https://www.cnblogs.com/Jtuzi/p/9459511.html