日期格式验证

来源:百度知道 编辑:UC知道 时间:2024/06/18 22:35:21
年月输入的验证格式判断怎么写?
格式如下:200703(年月输入)

正则表达式如下:
"^/d{4}((0[1-9])|(1[0-2]))$"

年只需输入四个数字即可,月份只允许01--12

特有的数字类型,比如int是整型的,输入错了就会提示错误;没记错的话是Data型

"^2\d{3}((0\d)|(1[0,2]))&"

用栏目专家aries1001 的吧,省事

用JS来做更好一些:
前台页面:(注意要在头部添加引用JS)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>test</title>
<script language="javascript" src="Inc/common.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txt_GetTime" runat="server" onchange="checkDate();" />
<div id="div_error" style="width:300px; height:150px"></div>
</body>
</html>

JS文件:"common.js"
f