JS和CSS学习笔记

JS学习笔记

1.跳转   <td colspan="2" align="center"><input type="button" name="Regesit" value="注册 "  onclick="window.location.href='regesit.jsp';"/></td>

跳转到 注册页面

2.按钮完成验证(两种方法)

(1)

<input type="submit" name="Submit" value="登录" onclick="return check();"/>

(2)
<form action="regesit" method="post" name="form1" onsubmit= "javascript:return chk_value(this);">
<form action="regesit" method="post" name="form1" onsubmit= "return chk_value(this);">

建议第二种,因为方法一是要点击鼠标,而有时候直接按回车方法一就费了,所以方法二很有效,是提交的时候判段。
3.表单无法完全验证比较
  (1)。有效方法:
var eleValue = document.formName.txtUserID.value;
if(eleValue == "")
{
alert("please input your username!");
document.formName.txtUserID.focus();
return false;
}

eleValue = document.formName.pwdUserPWD.value;
if(eleValue == "")
{
alert("please input your password!");
document.formName.pwdUserPWD.focus();
return false;
}
(2)无效方法:
  if(form1.regesitName.value==""){
alert("ÇëÊäÈëÓû§Ãû");
return false;
}
if(form1.regesitPwd.value==""){
alter("ÇëÊäÈëÃÜÂë");
return false;
}
第二种方法始终无法完成验证,原因暂且不知道
posted @ 2011-09-26 17:32  java_li  阅读(197)  评论(0编辑  收藏  举报