主题:散分求救
[em10]在用表单传送数据前,我用下列代码校验数据的有效性。
定义表单:
<form id="form1" name="form1" method="post" action = "sjcl.asp " onSubmit="return ChkFields() " runat="server" >
<input type="text" name="txt1" value="" style="overflow-x:visible;width:100;"/>
……
<input type="submit" value="保 存">
</form>
在同一页面中定义过程ChkFields():
<script language="VBScript">
function ChkFields()
if document.form1.txt1.value = "" Then '用户名没有输入
window.alert("请输入用户名") '给出提示
form1.txt1.focus() '将用户名文本框设为输入焦点
return false
End If
End Function
</script>
为了测试,我故意不输入用户名,但当我按“保存”按钮时,页面虽有提示,但不容修改就直接转到了sjcl.asp页面,似乎过程ChkFields()中的“return false”一句不存在一样。
怎么办呀?快来呀!散分求解!
[em1]
定义表单:
<form id="form1" name="form1" method="post" action = "sjcl.asp " onSubmit="return ChkFields() " runat="server" >
<input type="text" name="txt1" value="" style="overflow-x:visible;width:100;"/>
……
<input type="submit" value="保 存">
</form>
在同一页面中定义过程ChkFields():
<script language="VBScript">
function ChkFields()
if document.form1.txt1.value = "" Then '用户名没有输入
window.alert("请输入用户名") '给出提示
form1.txt1.focus() '将用户名文本框设为输入焦点
return false
End If
End Function
</script>
为了测试,我故意不输入用户名,但当我按“保存”按钮时,页面虽有提示,但不容修改就直接转到了sjcl.asp页面,似乎过程ChkFields()中的“return false”一句不存在一样。
怎么办呀?快来呀!散分求解!
[em1]

您所在位置: