社区
ASP
帖子详情
怎样验证我当前的Text框是否为空?
huang_2
2002-08-01 10:41:15
我原先的做法就是把form提交后再检查上一个页面的某个框是否为空,能否在我点击提交按钮的时候立即检查当前输入框是否为空,并且弹出一个提示框
...全文
90
12
打赏
收藏
怎样验证我当前的Text框是否为空?
我原先的做法就是把form提交后再检查上一个页面的某个框是否为空,能否在我点击提交按钮的时候立即检查当前输入框是否为空,并且弹出一个提示框
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
zhuyuantan
2002-08-01
打赏
举报
回复
form 表单里面有个 onsubmit="return function()" 的东东
return false 和return true 表示该 function() 返回真或假
如果返回真就执行 form 表单的 action 动作, 返回假就不执行 action 动作
huang_2
2002-08-01
打赏
举报
回复
return false 和 return true 分别起什么作用?
huang_2
2002-08-01
打赏
举报
回复
太感动了,这么多热心人
JavaCoffee
2002-08-01
打赏
举报
回复
<input type="text" name="txttest" size="20" onblur="if (this.value=='') alert('不能为空!');">
MeXP
2002-08-01
打赏
举报
回复
更正
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
function checkdata()
{
if (form1.aaa.value=="")
{
form1.aaa.focus();
alert("Please input");
return false;
}
else
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<form name="form1" method="post" action="" onsubmit="return checkdata()">
<input type="text" name="aaa" >
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
yhncom_36de
2002-08-01
打赏
举报
回复
给你一个例子,很实用的,可要给分呀!把代码粘贴后运行:代码如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)
{
if (theForm.username.value=="")
{
alert("请输入用户名!");
theForm.username.focus();
return (false);
}
return (true);
}
//--></script>
<table cellpadding=0 cellspacing=1 border=0 align=center>
</table>
<form method="POST" action="file:///C:/Inetpub/wwwroot/web/addok.asp" onsubmit="return FrontPage_Form1_Validator(this)" name="FrontPage_Form1" language="JavaScript">
<table border=1 cellspacing=0 width=750 height="12" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0">
<tr>
<td class=p2 align=right width="167" height="1"><font color=FF9933>*</font>用户名</td>
<td class=p2 align=right width="6" height="1"> </td>
<td bgcolor=E5E6D3 width="7" height="1"> </td>
<td bgcolor=E5E6D3 width="241" height="1"><b>
<input name=username size=25 type=text maxlength=14 style="font-size: 12px"></b></td>
<td class=p2 bgcolor=E5E6D3 nowrap width="313" height="1">用户名最多为10个字符或数字</td>
</tr>
</table>
<hr align=center noshade width=100% color=black>
<p align="center"><input type="submit" value="提交" name="B1"> <input type="reset" value="重写" name="B2"></p>
</form>
</body>
</html>
meizz
2002-08-01
打赏
举报
回复
<form onsubmit="return cc()">
<input type=text name=tt>
<input type=submit value=ok></form>
<script language=javascript>
function cc()
{
if (document.all.tt.value=="")
{
alert("输入框不能为空");
document.all.tt.focus();
return false;
}
return true;
}
</script>
ChinaOk
2002-08-01
打赏
举报
回复
看看faq
grooving
2002-08-01
打赏
举报
回复
javascript:
function check(){
if(document.form1.textbox1.value.length==0){
alert("空");
return false;
}
retrun true;
}
在onsumit事件里return check();
jhlcss
2002-08-01
打赏
举报
回复
If trim(document.all("txtname").value)="" Then
msgbox "不能为空"
End If
jo_yoko
2002-08-01
打赏
举报
回复
<HTML>
<head>
<script language="javascript">
function check()
{
if (form1.txt.value=="")
{
alert("不得为空");
return false;
}
else
form1.submit();
}
</script>
</head>
<body>
<form name="form1" action="???.asp">
<input type="text" name="txt" ><br>
<input type="button" name="btn" onclick="check();">
</form>
</body>
</HTML>
MeXP
2002-08-01
打赏
举报
回复
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
function checkdata()
{
if (form1.aaa.value="")
{
form1.bbb.focus();
alert("Please input");
return false;
}
else
return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" >
<form name="form1" method="post" action="" onsubmit="return checkdata()">
<input type="text" name="aaa" >
</form>
</body>
</html>
JavaScript检查表单
是否为空
的函数
本篇文章将详细介绍一个JavaScript函数,该函数可以用于检查表单中的文本
框
(`<input type="
text
">`)
是否为空
以及检查单选按钮(`<input type="radio">`)或复选
框
(`<input type="checkbox">`)是否被选中。...
javascript
验证
大全
- **复选
框
是否被选中
验证
** (`r_cb`):遍历
当前
表单的所有元素,检查指定的复选
框
是否被选中。 - **下拉列表选项是否被选中
验证
** (`r_sl`):检查下拉列表是否有选项被选中。 - **非空
验证
** (`r`):如果输入
框
为空...
VB图书管理系统源代码.docx
- **输入
验证
:**确保查询关键词不为空。 - **数据库查询:**通过`Adodc1.Recordset`遍历记录集,寻找匹配的图书名称。 - **结果反馈:**通过消息
框
显示查询结果。 #### 四、界面控制与系统维护 除了上述登录
验证
...
IOS alertView
在实际开发中,你可能还需要对输入进行
验证
,例如检查文本
是否为空
,或者密码是否满足特定的复杂性要求。你也可以自定义`UIAlertAction`的样式、颜色等属性,以适应应用的设计风格。 通过这种方式,我们可以在iOS...
jQuery实现批量判断表单中文本
框
非空的方法(2种方法)
如果值为空,会弹出警告消息,并将焦点设置回
当前
文本
框
,阻止表单的提交。 ### 方法二:自定义函数与数组参数的批量
验证
方法二中,我们创建一个名为`checkForm`的自定义函数,该函数接受一个数组作为参数,数组...
ASP
28,409
社区成员
356,968
社区内容
发帖
与我相关
我的任务
ASP
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
复制链接
扫一扫
分享
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章