文本框应以24小时格式接受时间 [英] Textbox should accept time in 24 hour format

查看:68
本文介绍了文本框应以24小时格式接受时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,



给我正则表达式或javascript,这样用户只能在24小时格式化时输入时间。那就是用户输入时间如01 :30,不允许。

我使用两个文本框时间:

1小时和第二个文本框分钟

提前感谢。

解决方案

我建​​议您使用 Timepickers [< a href =http://plugins.jquery.com/tag/timepicker/target =_ blanktitle =新窗口> ^ ],你可以在网上找到很多。不要在验证上浪费你的时间。这些jQuery插件将减轻您的麻烦。


ajax控件中的用户TimeSelector

这可以通过设置属性SelectedTimeFormatto TwentyFour来完成,这会将时间格式更改为24 TimePicker中的小时时钟。



< cc1:TimeSelector ID =TimeSelector7runat =serverSelectedTimeFormat =TwentyFour> < / cc1:TimeSelector> 







获取更多详细信息


您好@Aysha你可以简单地使用DropDownList而不是Textbox,如下面的代码

 <   div  >  
< asp:dropdownlist id = DropDownList1 runat = server xmlns:asp = #unknown >
< asp:listitem > 13:30 < / asp:listitem >
< asp:listitem > 14:00 < / asp:listitem >
<% -
等等添加所有时间
- %>
< / asp:dropdownlist >
< ; / div >





希望它能为您提供帮助。


hii friends,

give me regular expression or javascript so that user can only able to input time in 24 hours formate.That is if user inputting time like 01:30 ,not allowed.
I use two textbox for time:
1 for hour and 2nd textbox for minute
thanks in advance.

解决方案

I suggest you to go with Timepickers[^], you could find many in web. Don't waste your time on validations. These jQuery plugins will reduce your headaches.


User TimeSelector in ajax control
This can be done by setting the property SelectedTimeFormatto TwentyFour, this changes the Time Format to 24 hour clock in the TimePicker.

<cc1:TimeSelector ID="TimeSelector7" runat="server" SelectedTimeFormat="TwentyFour"></cc1:TimeSelector>




Get more details


Hi @Aysha you can simply use DropDownList instead of Textbox as below code

<div>
        <asp:dropdownlist id="DropDownList1" runat="server" xmlns:asp="#unknown">
            <asp:listitem>13:30</asp:listitem>
            <asp:listitem>14:00</asp:listitem>
            <%--
            so on add all timings
            --%>
        </asp:dropdownlist>
    </div>



Hope it will help you.


这篇关于文本框应以24小时格式接受时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆