if(s.value == null || s.length ==0){
alert("不能为空!");
return false;
}
解决方案 »
- 第三次发帖:JQuery如何实现QQ音乐播放器图片特效?
- 谁有好的文字特效
- 如实现 文本框输入一些字符然后在当前鼠标后动态添加一些提示文字
- 求助
- XMLHttpRequest 非常菜鸟级问题
- 一个简单的字符替换问题
- 求解决问题,分不够可以再加,raphael画中国热点图
- 急问一个简单的Js问题....waiting Online....
- 可以实现对iframe的隐藏和显示的控制吗?
- 世界地图!
- 用 javascript 动态加入 控件后,如后查看他的HTML源代码 ?
- 怎样在用window.showModalDialog打开的窗口里调用 用window.showModalDialog这个函数页面上的函数?
alert("用户名称不能为空!");
txtUserName.focus();
return false;
}
<!--
function check(thisform){
if(thisform.username.value==""){
alert("sorry,username can't be blank");
return false;
}
return true;
}
//-->
</script><form action="http://www.sina.com.cn" method="post" onsubmit="return check(document.frm01);" name="frm01>
<input type="text" name="username">
<input type="submit" value="submit">
</form>
function checktext(){
if(document.tttt.textarea.value=="")
{ alert("请填写您的留言内容!!");
document.tttt.textxareaa.focus();
return false;
}
</script>
然后在form里加上
<form name="from1 action="..." method="post" onsubmit="return checktext();" >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javaScript">
function checkit()
{
if(document.form1.s.value =="" ||document.form1.s.length ==0){
alert("不能为空!");
return false;
}
}
</script>
<title>无标题文档</title></head><body>
<form name="form1" action="" method="post">
姓名:<input type="text" name="s" >
<input type="submit" name="go" value="提交" onClick="return(checkit());">
</form>
</body>
</html>
<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>
<form name="frm1" method="post" action="">
<body>
<input name="a" type="text">
<p>
<a onclick ="vbscript:checkform" href="#" class="button">提交</a>
</form>
</body>
</html>
<script language="vbscript">
<!--
sub checkform()
if frm1.a.value="" then
msgbox "不能空,请填写",vbExclamation,""
frm1.a.focus()
exit sub
end if
end sub
-->
</script>
<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>
<form name="frm1" method="post" action="">
<body>
<input name="a" type="text">
<p>
<input type="button" value="保存(S)" accesskey="S" id=submit1 name=submit1 onclick="subcheck()">
</form>
</body>
</html>
<script LANGUAGE="javascript">
<!--
function subcheck(){
a=new String(document.all.a.value)
if("$"+a=="$"||"$"+a=="$undefined"){
alert("请输入内容!");
document.all.a.focus()
return false
}
document.frm1.submit()
}//-->
</script>