87,910
社区成员
发帖
与我相关
我的任务
分享
<html>
<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>