Home > Software engineering >  how to insert time in a textbox in asp.net
how to insert time in a textbox in asp.net

Time:09-29

I want the users insert hour and minutes by them selves into a textbox in asp .net.I want when they insert hour,automatically ":" appears and cursor jump over the ":" so user can insert minute. Is there a method for this aim?

CodePudding user response:

Well, you can just drop in a plane jane textbox, like this:

<asp:TextBox ID="TextBox1" runat="server" TextMode="Time"></asp:TextBox>

If you set the above text mode, then you get a box in which you can type in the hours, it shows : and you don't have to hit tab or anything. In the next area, you then get to type in minutes, and then it jumps to AM/PM, you can type a A or P.

So the whole time entry can be done via keyboard, it looks like this:

enter image description here

So if you type in 06 it will jump to minutes, and same goes for minutes section.

This takes zero code and is built into asp.net

So try the TextMode="Time" for a regular text box

  • Related