<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button7" runat="server" OnClick="Button7_Click" OnClientClick="javascript:return checkForm()" Text="提交" />
</form>
Javascript代码块
<script language="javascript" type="text/javascript">
function checkForm() {
if (document.form1.TextBox1.value == "") {
alert("怎么是空的!");
document.form1.TextBox1.focus();
return false;
}
var length = document.form1.TextBox1.value.length;
if (length < 6 || length > 10) {
alert("必须是6~10个字符内!");
return false;
}
}
</script>
新闻热点
疑难解答