用户在文本中输入日期和时间如果不规范保存就会出错,我想用一个能输入日期和时间的控件来避免这个错误,哪位朋友有什么好的方法吗?

解决方案 »

  1.   

    datetimepicker本来就支持输入的
      

  2.   

    只有日期控件,不支持时间,需要到www.aspxcn.org下载!
      

  3.   

    to jinjazz(近身剪(充电中...))  webform也有这个控件吗?
    to wufeng0524(高处不胜寒)   怎么没有找到呢?
      

  4.   

    to wufeng0524(高处不胜寒)  我需要能输入时间的
      

  5.   

    给我你的email 我发一个修改后的梅花雪的 可以选择时间的
      

  6.   

    to jinjazz(近身剪(充电中...))  正则没有用过,怎么写阿? 
    需要这样的格式 'yyyy-mm-dd HH:mm' 还要要求正确的日期和时间
      

  7.   

    to hcqhappy(月坏)  好的,[email protected],谢谢了
      

  8.   

    CompareValidator,RangeValidator控件都提供这样的功能,把type设置为Date不就可以了?
      

  9.   

    看看這個:
    a.htm
    ______________________________________________________________
    UI:<br><INPUT type="text" name=text1  >
    <INPUT type="button" value="Date" name="pickDate"  onclick="aaa(this);">
    <br><INPUT type="text" name=text2>
    <INPUT type="button" value="Time" name="pickTime"  onclick="aaa(this);" >
    <br><INPUT type="text" name=text3>
    <INPUT type="button" value="Date and Time" name="pickAll" onclick="aaa(this);">
    <SCRIPT>
    function aaa(obj)
    {
    var para="scroll:no;status:no;center:yes;unadorned:no;dialogHeight:200px;dialogWidth:"
    switch (obj.name) 
    {
    case "pickDate" :
    //choose date only
             para+="450px;"
     break;
    case "pickTime" :
    //choose time only
    para+="200px;";
    break;
    case "pickAll" :
    // choose all
    para+="450px;";
    break;
    }
    window.showModalDialog("time.htm" ,obj, para)}</SCRIPT>
    ______________________________________________________________time.htm
    ______________________________________________________________
    <HTML>
    <HEAD> 
    <TITLE>DateTimePicker</TITLE>
    <style>
    body 
    {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    background-color: #d4d0c8;
    }
    input.txt

    BORDER-TOP: lightgrey 1px solid; 
    BORDER-LEFT: lightgrey 1px solid;
    BORDER-RIGHT:lightgrey 1px solid;
    BORDER-BOTTOM: lightgrey 1px solid; 
    BACKGROUND-COLOR: #d4d0c8;
     }
      input.btn {
    font-family: 宋体 Fixedsys; 
    font-size:12px;
    BORDER-RIGHT: royalblue 1px solid;
    BORDER-TOP: royalblue   1px solid;
    BORDER-LEFT: royalblue 1px solid;
    LINE-HEIGHT: 16px; 
    BORDER-BOTTOM: royalblue 1px solid; 
    HEIGHT: 18px;
    BACKGROUND-COLOR: lightblue; 
    cursor:hand;
    COLOR: royalblue; 
     }
    body,td {
    font-size: 12px;
    }
    .N
    {
    display:none;
    }
    .B
    {
    display:block;
    }
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"></HEAD>
    <BODY>
    <table width="98%" height="170"  border="1" align="center" cellpadding="0" cellspacing="0" >
      <tr>
        <td width="270" id=tdDate  >
          <OBJECT id=C1 height=170 width=270  onMouseMove="setDate();"
          classid=clsid:8E27C92B-1264-101C-8A2F-040224009C02></OBJECT></td><td width="180" align="center" valign="middle">     
      
            <table width="100%"  border="0" cellpadding="0" cellspacing="0" id=tbTime>
            <tr>
              <td align="center" scope=row>系统时间 <span id=text1></span> </td>
            </tr>
            <tr>
              <td align="center" scope=row>设置时间:</td>
            </tr>
            <tr>
              <td align="center" scope=row><select id=s1 onchange="settime();"></select >点<select id=s2 onchange="settime();"></select>分<select id=s3 onchange="settime();"></select>秒</td>
            </tr>
            <tr>
              <td align="center" scope=row><input id="text2" ></td>
            </tr>
          </table>
            <table width="100%"  border="0" cellspacing="0" cellpadding="0" id="tbDate">
              <tr>
                <td align="center" scope="row">日期: <br>
                <input  id="text3"></td>
              </tr>
            </table>
            <br>
        <input type="button" onClick="rtn();" value="确定"></td>
      </tr>
    </table>
    <br>
    <br>
    <SCRIPT>
    switch (window.dialogArguments.name) 
    {
    case "pickDate" :
            tbTime.className ="N";
            setDate();
            break;
    case "pickTime" :
    tbDate.className ="N";
    tdDate.className="N";
    iniTime();
    break;
    case "pickAll" :
    setDate();
    iniTime();} 
    function iniTime()
    {
    text1.innerText=getMyTime(); 
    addAll(s1,23);
    addAll(s2,59);
    addAll(s3,59);
    d = new Date();
    s1.selectedIndex=d.getHours();
    s2.selectedIndex=d.getMinutes();
    s3.selectedIndex=d.getSeconds();
    window.setInterval("text1.innerText=getMyTime();","1000");
    settime();
     }
    function getobj(obj)
    {
    for(i=1;i<obj.document.all.length;i++)
    {
    if(obj==obj.document.all(i))
    {
    return(obj.document.all(i-1))
    }
    }
    }
    function settime()
    {
    text2.value=s1.value+":"+s2.value+":"+s3.value;
    }
    function setDate()
    {
    if(text3.value != C1.Year + "-" + C1.Month + "-" + C1.Day)
    {
    text3.value=C1.Year + "-" + C1.Month + "-" + C1.Day;
    }
    }
    function rtn(obj)
    {
    var r=new String("");
    r=text3.value + " " + text2.value;
    r=r.replace(/(^[\s]*)|([\s]*$)/g, "");
    getobj(window.dialogArguments).value=r;
    self.close(); 
    }function getMyTime(){
       var d, s = "";
       var c = ":";
       d = new Date();
       s += d.getHours() + c;
       s += d.getMinutes() + c;
       s += d.getSeconds(); 
       return(s)  ;
    }
    function addAll(obj,n)
    {
    var ooo=document.createElement("<OPTION>");
    for(i=0;i<=n;i++)
    {
     add(obj,i,i);
    }
    }
    function add(obj,v,t)
    {
    var ooo=document.createElement("<OPTION>");
    ooo.value=v;
    ooo.text=t;
    obj.add(ooo);
    }
    </SCRIPT>
    </BODY>
    </HTML>______________________________________________________________
      

  10.   

    谢谢各位,非常感谢hcqhappy(月坏)