预想使用focus等事件,考虑到浏览器不支持的缘故,便使用了
页面代码
<%@ 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>委员基础信息维护</title> <!-- 加载easyui样式表 --> <link rel="stylesheet" type="text/css" href="plugins/jquery/jquery-easyui-1.1.2/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="plugins/jquery/jquery-easyui-1.1.2/themes/icon.css"> <!-- 加载jquery --> <script type="text/javascript" src="plugins/jquery/jquery-1.4.2.min.js"></script> <!-- 加载easyui --> <script type="text/javascript" src="plugins/jquery/jquery-easyui-1.1.2/jquery.easyui.min.js"></script> <!-- 加载jquery-form --> <script type="text/javascript" src="plugins/jquery/jquery.form.js"></script> <!-- 加载自定义js --> <script type="text/javascript" src="javascript/sysmanage/personinfo.js"></script> </head> <body style="background: #c7dcf1;"> <form id="upForm" method="POST" enctype="multipart/form-data"> <table> <tr> <td> <input type="button" name="" id="" value="委员维护" onclick="show_win()"> </td> </tr> </table> <div id="win" style="background-color: #d1e1f0;" model="true"> <br> <fieldset> <legend style="font-size: 14; font-weight: bold"> 委员基本信息 </legend> <div style="float: left;"> <table width="1150" border="0"> <tr> <td width="155" >委员证号:</td> <td width="97" ><label> <input type="text" name="committeemannumber" id="committeemannumber" size="13"/> </label></td> <td width="94" >届次:</td> <td width="97"><label> <input type="text" name="sessions" id="sessions" size="13"/> </label></td> <td colspan="4"> </td> <td colspan="2" rowspan="6"> <div id="right" style="float: none; text-align: center;"> <div style="width: 120px; height: 150px; background-color: #cccccc"> <img id="userPhoto"/> </div> <br> <input type="button" id="" name="" value=" 上传 " onclick="return show_upload();"> <input type="button" value=" 修改 "> <div id="uploadWin" class="easyui-window" title="My Window" closed="true"> <!-- <form id="upForm" method="POST" enctype="multipart/form-data"> 上传文件:<input type="file" name="file" id="theFile"/> <br/> <input type="submit" value="提交" onclick="return upload();"/> <input type="button" value="取消" /> <div id="upMessage" style="displan:hidden"></div> </form> --> 上传文件:<input type="file" name="file" id="theFile"/> <br/> <input type="submit" value="提交" onclick="return upload();"/> <input type="button" value="取消" /> <div id="upMessage" style="displan:hidden"></div> </div> </div> </td> </tr> <tr> <td>姓名:</td> <td><label> <input type="text" name="name" id="name" size="13" /> </label></td> <td>性别:</td> <td><label> <input type="text" name="sex" id="sex" size="13"/> </label></td> <td width="113">民族:</td> <td width="97"><label> <input type="text" name="nationality" id="nationality" size="13"/> </label></td> <td width="103">出生日期:</td> <td width="97"><label> <input type="text" name="birthday" id="birthday" size="13" class="easyui-datebox"/> </label></td> </tr> <tr> <td height="26">工作系统:</td> <td><label> <input type="text" name="worksystem" id="worksystem" size="13"/> </label></td> <td>所在地:</td> <td><label> <input type="text" name="locus" id="locus" size="13"/> </label></td> <td>保密电话:</td> <td><label> <input type="text" name="secrettelephone" id="secrettelephone" size="13"/> </label></td> <td>学历:</td> <td><label> <input type="text" name="degree" id="degree" size="13"/> </label></td> </tr> <tr> <td>单位名称:</td> <td colspan="3"><label> <input type="text" name="unit" id="unit" size="50"/> </label></td> <td>行政级别:</td> <td><label> <input type="text" name="rank" id="rank" size="13"/> </label></td> <td>单位电话:</td> <td><label> <input type="text" name="unittelephone" id="unittelephone" size="13"/> </label></td> </tr> <tr> <td>现任职务:</td> <td colspan="3"><label> <input type="text" name="post" id="post" size="50"/> </label></td> <td>社会兼职:</td> <td colspan="3"><label> <input type="text" name="sideline" id="sideline" size="50"/> </label></td> </tr> <tr> <td>单位地址:</td> <td colspan="3"><label> <input type="text" name="unitaddress" id="unitaddress" size="50"/> </label></td> <td>单位邮编:</td> <td><label> <input type="text" name="unit_number" id="unit_number" size="13"/> </label></td> <td>交换箱号:</td> <td><label> <input type="text" name="exchangeboxnumber" id="exchangeboxnumber" size="13"/> </label></td> </tr> <tr> <td>家庭地址:</td> <td colspan="3"><label> <input type="text" name="houseaddress" id="houseaddress" size="50"/> </label></td> <td>家庭邮编:</td> <td><label> <input type="text" name="housepostalcode" id="housepostalcode" size="13" /> </label></td> <td>家庭电话:</td> <td><label> <input type="text" name="housetelephone" id="housetelephone" size="13"/> </label></td> <td width="142">手机号:</td> <td width="91"><label> <input type="text" name="mobiletelephone" id="mobiletelephone" size="13"/> </label></td> </tr> <tr> <td height="31">电子邮箱:</td> <td colspan="3"><label> <input name="email" type="text" id="email" size="50"/> </label></td> <td>文件去向:</td> <td><label> <input type="text" name="docwhither" id="docwhither" size="13"/> </label></td> <td>职业专长:</td> <td><label> <input type="text" name="occupation" id="occupation" size="13"/> </label></td> <td>职称:</td> <td><label> <input type="text" name="professiontitle" id="professiontitle" size="13"/> </label></td> </tr> <tr> <td>参政日期:</td> <td><label> <input type="text" name="franchisedate" id="franchisedate" size="13" class="easyui-datebox"/> </label></td> <td>党派:</td> <td><label> <input type="text" name="party" id="party" size="13"/> </label></td> <td>小组:</td> <td><label> <input type="text" name="team" id="team" size="13"/> </label></td> <td>界别:</td> <td><label> <input type="text" name="sector" id="sector" size="13"/> </label></td> <td>政协职务:</td> <td><label> <input type="text" name="pccpost" id="pccpost" size="13"/> </label></td> </tr> <tr> <td>专委会及职务:</td> <td colspan="2"><label> <input type="text" name="committee" id="committee" size="28"/> </label></td> <td><label> <input type="text" name="committeepost" id="committeepost" size="13"/> </label></td> <td>当前状态:</td> <td colspan="3"><label> <input type="text" name="currentstatus" id="currentstatus" size="50"/> </label></td> <td>当前状态日期:</td> <td><label> <input type="text" name="currentstatusdate" id="currentstatusdate" size="13" class="easyui-datebox"/> </label></td> </tr> <tr> <td>司机姓名:</td> <td colspan="3"><label> <input type="text" name="driver_name" id="driver_name" size="50"/> </label></td> <td>司机电话:</td> <td colspan="3"><label> <input type="text" name="driver_telephone" id="driver_telephone" size="50"/> </label></td> <td>车牌:</td> <td><label> <input type="text" name="car_number" id="car_number" size="13"/> </label></td> </tr> <tr> <td>简介:</td> <td colspan="9"><label> <textarea name="resume" id="resume" cols="90" rows="5"></textarea> </label></td> </tr> </table> </fieldset> <br> <fieldset> <legend style="font-size: 14; font-weight: bold"> 委员用户信息 </legend> <table> <tr> <td> <label> 用户名: </label> <input type="text" name="username" id="username" size="32"> </td> <td> <label> 用户密码: </label> <input type="password" name="password" id="password" size="32"> </td> <td> <label> 用户密码确认: </label> <input type="password" name="confirmPassword" id="confirmPassword" size="32"> </td> </tr> </table> </fieldset> <div style="clear: both; text-align: center;"> <table> <tr> <td> <input type="submit" value=" 确定 " onclick="return submitInfo();"> <input type="button" value=" 取消 " onclick="return close_win();"> </td> </tr> </table> </div> </div> </form> </body> </html>
判断其中任意一个文本框的值是否被修改
//绑定事件 //为界面上的所有元素添加focusin和focusout事件, //用于判断用户是否修改了该值 function bindEvent() { var temp; $("#committeemannumber,#sessions,#name,#committeemannumber,#sessions,#username,#sex,#nationality,#birthday,#worksystem,#locus,#secrettelephone,#degree,#unit,#rank,#unittelephone,#post,#sideline,#unitaddress,#exchangeboxnumber,#houseaddress,#housepostalcode,#housetelephone,#mobiletelephone,#email,#docwhither,#occupation,#professiontitle,#franchisedate,#party,#team,#sector,#pccpost,#committee,#committeepost,#currentstatus,#currentstatusdate,#resume,#car_number,#driver_name,#driver_telephone,#unit_number").bind({ focusin:function (){ //取得当前元素的id //alert(this.id); //alert("获得焦点时的值是:"+$(this).val()); temp=$(this).val(); }, focusout:function (){ //alert("失去焦点时的值是:"+$(this).val()); var lastValue=$(this).val(); if(temp!=lastValue&&null!=lastValue&&""!=lastValue) { alert("值改变了!"); } else { alert("没有变!"); } } }); }
当然需要
$(document).ready(function() { bindEvent(); });