<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>replaceHref</title>
</head><body>
<script >
function cc(){
if(/(^ *| *$)/.test(document.getElementsByName("aaa")[0].value)){
alert(" :have")
return false;
}
}
</script>
<form name= "form1 " method= "post " action= "http://www.csdn.net " onsubmit="return cc()" >
<input name= "aaa" type= "text " />
<input type=submit name=button value= "bbb " />
</form>
</body></html>另 name不要用id这种关键字
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>replaceHref</title>
</head><body>
<script >
function cc(){
if(/(^ *| *$)/.test(document.getElementsByName("aaa")[0].value)){
alert(" :have")
return false;
}
}
</script>
<form name= "form1 " method= "post " action= "http://www.csdn.net " onsubmit="return cc()" >
<input name= "aaa" type= "text " />
<input type=submit name=button value= "bbb " />
</form>
</body></html>另 name不要用id这种关键字
解决方案 »
- 星星打分
- js高手来 ,差生随机字符串
- jscript如何设置jsp中的控件(inputtext)的光标呢? 在线
- 关与电子地图的问题
- 100分请各位高手帮小弟解决一个图片剪切的功能(急)
- [求助]在菜单的DIV层中用了iframe,可以挡住单行的Select,可在多行的Select上展开菜单时,Select会闪烁出现呢?
- 输入检查 对输入的字符串格式进行判断
- 怎样才能关闭showModalDialog打开的对话框?
- swfupload在ie9中,以模态窗口打开,点击添加文件按钮会出现浏览器卡死
- vue莫名其妙改变值,求大神解答,急急急
- 急急急~~下拉菜单值显示问题~~
- 请教一个弹出 DIV 定位的问题。
<head></head>
<script>
function chk(f)
{
var id=f.id.value;
if(id=="")
{
alert("id不能为空!");
f.id.focus();
return false;
}
if(id.charAt(0)==" "||id.charAt(id.length-1)==" ")
{
alert("id前面或者后面不能有空格!");
f.id.focus();
return false;
}
}
</script>
<body>
<form name="form1" method="post" action= "http://www.csdn.net" onsubmit="return chk(this)">
<input name="id" type="text" />
<input type=submit name=button value="提交" />
</form> </body>
</html>