javascript 学习之确认表单必填项目

July 12, 2011 | tags | views
Comments 0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>无标题文档</title>
<script type="text/javascript">
  
 
   function check_submit(){
   alert("good")
     if($("txt_admin").value==""){ alert("请输入用户名"); return(false)}
  if($("txt_pass").value==""){ alert("请输入密码"); return(false)}
  if($("txt_passcopy").value==""){ alert("请再次输入密码"); return(false)}
   }
   function $(str){return(document.getElementById(str));}
</script>
</head>

<body>
<form action="" onSubmit="check_submit();">
用户名:<br />
<input id="txt_admin" type="user_admin" />
<br />
密码:<br />
<input id="txt_pass" type="password" /><br />
重复密码:
<br />

<input id="txt_passcopy" type="password" />
<br />
 <input type="submit" value="提交">
</form>
</body>
点击查看效果


    相关文章:



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。