ASP判断表单提交的文本字段是否为空

在asp表单中我有三个文本字段 f_title f_content f_other

当访问者提交表单 时通过js判断输入值是否为空

当然为空的话就不能让sql语句继续写入数据库了

两种方法.一是用JS
function CheckForm()
{
if(document.form(表单名).f_title(元素名).value=="")
{
alert("不能为空!");
document.form(表单名).f_title(元素名).focus();
return false;
}
...
}

第2种用ASP
<%if request.form(f_title)<>"" or request.form(f_content)<>"" or request.form(f_other)<>"" then
接下来写你要执行的语句
%>

有问题加个群2976157
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-08-03
<script language="javascript" type="text/javascript">
function check(){
if(form.f_content.value=="")
{
f_content.innerHTML = "不能为空!";
form.f_content.focus();
return false;
}
else
{
f_content.innerHTML = "";
}
if(form.f_title.value=="")
{
f_title.innerHTML = "不能为空!";
form.f_title.focus();
return false;
}
else
{
f_title.innerHTML = "";
}

if(form.f_other.value=="")
{
f_other.innerHTML = "不能为空!";
form.f_other.focus();
return false;
}
else
{
f_other.innerHTML = "";
}

return true;
}
</script>

<form action="#####" method="post" name="form" target="_self" onSubmit="return check()">
f_title :<input name="f_title " type="f_title " id="f_title " ><label id="f_title"></label>
<br>
f_content:<input name="f_content" type="text" id="f_content" ><label id="f_content"></label>
<br>
f_other:<input name="f_other" type="text" id="f_other" ><label id="f_other"></label>
<br>
<input type="submit" name="Submit" value="添加">
</form>
第2个回答  2013-08-03
js啊??

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网