指定jquery文本框的时间格式

来源:互联网 发布:手机听英语单词软件 编辑:程序博客网 时间:2024/04/28 19:39
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@include file="pagerHeader.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>aaa</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" src="<%=basePath %>js/jquery-1.7.2.min.js"></script>
<link href="<%=basePath %>/js/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>/js/themes/icon.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>/js/demo/demo.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath %>js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<%=basePath %>js/easyui/locale/easyui-lang-zh_CN.js"></script>


  </head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>日期:</td>
<td><input  required data-options="validType:'dates'" class="easyui-datebox"></td>
</tr>
</table>
<script>
       $.extend($.fn.validatebox.defaults.rules, {
   dates : {// 验证
      validator : function(value) { 
       //格式yyyy-MM-dd或yyyy-M-d
          return/^(?:(?!0000)[0-9]{4}([-]?)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-]?)0?2\2(?:29))$/i.test(value); 
      },
      message : '清输入合适的日期格式'
  }
       })
   </script>
</body>
</html>



0 0
原创粉丝点击