javascript 判断表单提交问题

来源:百度知道 编辑:UC知道 时间:2024/05/26 20:25:25
<script language="javascript">

function check()
{
chr aaa;
aaa=document.form1.text1.value
if (aaa=="")
window.alert("123");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="">
<label>
<input type="text" name="text1">
</label>
<label>
<input type="submit" name="Submit" value="提交">
</label>
</form>
</body>
</html>
以上是代码,每次执行程序的时候好像java的脚本代码不起作用。请问这是为什么

两处错误:
1 定义变量chr aaa;

2 没有加入检测语句

<script language="javascript">

function check()
{
var aaa;
aaa=document.form1.text1.value
if (aaa=="")
window.alert("123");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form name="form1" method="post" action="" language="javascript" onsubmit="return check()">
<label>
<input type="text" name="text1">
</label>
<label>
<input type="submit" name="Submit" value=