开始时单独导入到jsp的空白页面,时间的函数可以发挥作用,代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <html > <head> <title>My97date</title> <script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script> <script type="text/javascript" src="js/jquery-1.7.2.js"></script></head> <body> <form > <input id="sdate" class="Wdate" onfocus="WdatePicker({dateFmt:‘yyyy-MM-dd‘,readOnly:true,maxDate:‘#F{$dp.$D(\‘edate\‘)}‘})" /> - <input id="edate" class="Wdate" onfocus="WdatePicker({dateFmt:‘yyyy-MM-dd‘,readOnly:true,minDate:‘#F{$dp.$D(\‘sdate\‘)}‘,startDate:‘#F{$dp.$D(\‘sdate\‘,{d:+1})}‘})" /><br><br> <input type="text" id="time" class="Wdate" onfocus="WdatePicker({lang:‘zh-cn‘,dateFmt:‘yyyy-MM-dd‘})"/> </form> <script type="text/javascript"> $(function(){ $("#time").blur(function(){ var time =$(this).val(); if(time==""){ alert("请选择时间"); } }); }); </script> 上面的代码可以正常显示时间的格式
实际用到的页面为:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@taglib prefix="s" uri="/struts-tags"%> <% 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 ‘info.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"> </head> <body> <div class="action"> <div class="t"> 申请休假 </div> <div class="pages"> <form action="${pageContext.request.contextPath }/attence/addleave.action?usid=<s:property value=‘#session.user1.id‘ />" method="post" onsubmit="return checkAll()" enctype="application/x-www-form-urlencoded" target="_self1"> <table width="90%" border="0" cellspacing="0" cellpadding="0"> <tr > <td align="right" width="30%">姓名:</td><td align="left"><input type="text" onblur="checkUname()" name="at.aname" id="at.aname" /></td> </tr> <tr > <td align="right" width="30%">开始时间:</td><td align="left"><input type="text" id="sdate" name="at.astarttime" class="Wdate" onfocus="WdatePicker({dateFmt:‘yyyy-MM-dd‘,readOnly:true,maxDate:‘#F{$dp.$D(\‘edate\‘)}‘})" /><a style="color: red">*<span id="span1"></span> </a></td> </tr> <tr > <td align="right" width="30%">结束时间:</td><td align="left"><input type="text" id="edate" name="at.aendtime" class="Wdate" onfocus="WdatePicker({dateFmt:‘yyyy-MM-dd‘,readOnly:true,minDate:‘#F{$dp.$D(\‘sdate\‘)}‘,startDate:‘#F{$dp.$D(\‘sdate\‘,{d:+1})}‘})"/><a style="color: red">*<span id="span2"></span> </a></td> </tr> <tr > <td align="right" width="30%">请假天数:</td><td align="left"><input type="text" name="at.aday" id="aday"/><a style="color: red">*<span id="span3"></span></a></td> </tr> <tr > <td align="right" width="30%">请假原因:</td><td align="left"><textarea rows="2" cols="20" id="at.areason" name="at.areason"></textarea></td> </tr> <tr > <td align="right" width="30%">审批人:</td><td align="left"> <select id="at.lid" name="at.lid" > <s:iterator value="#session.userList1" var="user" status="status"> <option value="<s:property value=‘id‘/>"><s:property value="rname"/></option> </s:iterator> </select> </td> </tr> <tr > <td align="center" colspan="2"> <br/><input type="submit" id="save" value="提交申请" /> <input type="button" id="return" value="返回" onclick="window.history.back()" /> </td> </tr> </table> </form> </div> </div> </body> </html>
红色区域为时间插件可以显示的顺序,之前的顺序css在最前,其次是jQuery和时间的插件,修改后恢复正常,同时当时使用的是MyEclipse,需要重新启动方可正常显示,所以修改之后,要重新启动服务器.
时间: 2024-10-11 22:29:07