<SCRIPT language="Javascript"> function checkValues(){ var AccountID; var AccountIDLength; var passw; var passLength AccountIDLength=AccountID.length; passLength=passw.length; if(AccountIDLength==0){ alert("Login is empty!"); txtAccountID.focus(); } if(passLength==0) { alert("Password is empty!"); txtPass.focus(); } } </SCRIPT>
function checkValues(){
var AccountID;
var AccountIDLength;
var passw;
var passLength
AccountIDLength=AccountID.length;
passLength=passw.length;
if(AccountIDLength==0){
alert("Login is empty!");
txtAccountID.focus();
}
if(passLength==0)
{
alert("Password is empty!");
txtPass.focus();
}
}
</SCRIPT>
我想知道的是在我本身的程序里
<html:form action="/login">
<html:text property="name" />
<html:password property="password" redisplay="true" />
</html:form>
SCRIPT的方法应该在哪调用?就是加在标签的哪里?语法是什么?
在SCRIPT部分,没有FORM的名称,怎么获得FORM里的NAME和PASSWORD参数啊判断他们长度?谢谢了
function checkForm(){
if(document.form1.username.value==""){
alert('用户名不能为空!请重新填写!');
return false;
}
if(document.form1.password.value==""){
alert('密码不能为空!请重新填写!');
return false;
}
}
</script>再在表单里加入如下代码啊,完整代码如下:<form action="你要连接的网页名称" method="post" name="form1" id="form1" onsubmit="return checkForm()">