- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>无标题页</title>
- <script type="text/javascript">
- function isTime()
- {
- var text = document.getElementById("Text1");
- var patrn=/^/d{4}-/d{1,2}-/d{1,2}/s/d{2}:/d{2}:/d{2}$/;
- if (!patrn.exec(text.value))
- {
- alert("错误,请输入正确的时间格式.如:2008-12-12 12:00:00");
- text.value="2008-12-12 12:00:00";
- return false;
- }
- else
- return false;
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <input id="Text1" type="text" onblur="isTime();" value="2008-10-1 12:00:00"/><asp:Button ID="Button1" runat="server" Text="Button" /></div>
- </form>
- </body>
- </html>
结合日历控件使用的强制输入时分秒的js
最新推荐文章于 2024-04-30 22:56:29 发布