javascript表单事件

来源:互联网 发布:淘宝按摩颈椎的小仪器 编辑:程序博客网 时间:2024/06/10 04:05
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">    <title>My JSP 'index.jsp' starting page</title>    <meta http-equiv="pragma" content="no-cache">    <meta http-equiv="cache-control" content="no-cache">    <meta http-equiv="expires" content="0">        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="This is my page">    <!--    <link rel="stylesheet" type="text/css" href="styles.css">    -->    <script type="text/javascript">        function check_submit()        {          if($("text_user_name").value=="")          {             alert("请输入用户名!") ;            return (false);          }          if($("text_user_pass").value=="")          {            alert("请输入密码!");            return(false);               }          if($("text_usre_pass_confirm").value=="")          {            alert("请输入确认密码!");            return(false);          }          $("submit_botton").disabled = true;           return(false);          }          function $(str)          {            return(document.getElementById(str));          }          //当鼠标在对象上移动时          function mover()          {          //设置或获取触发事件对象  文本框对象focus方法将焦点移到该文本框 select方法选择该文本框内容              event.srcElement.focus();             event.srcElement.select();          }         //档鼠标单击操作时          function mclick()          {            if(event.srcElement.value()=="用户名")event.srcElenment.value=="";          }          //当对象失去焦点时          function mblur()          {             if(event.srcElement.value()=="")event.srcElenment.value=="用户名";          }    </script>  </head>  <body style="overflow: auto">    <form action="#" onsubmit="return check_submit();">          用户名:<br/><!-- onclic为鼠标单击操作事件  onblur为对象失去焦点  onmousemove为鼠标在对象上移动 -->         <input type="text" id="text_user_name" onmousemove="mover()" onclick="mclick()" onblur="mblur()" value="用户名"><br>         密码 :<br>         <input type="password" id="text_user_pass" onmousemove="mover()" value="密码"><br>    确认密码:<br>         <input type="password" id="text_user_pass_confirm" onmousemove="mover()" value="确认密码">         <br>         <input type="submit" value="提交" id="submit_button">              </form>  </body></html>

0 0
原创粉丝点击