Hi All,
I am using Windows C#.Net. and Maskedtext Box using for only Time Format..I need the Validation Time Format using Maskedtext Box..So please some examples...
Regards
Somasundaram G
Hi All,
I am using Windows C#.Net. and Maskedtext Box using for only Time Format..I need the Validation Time Format using Maskedtext Box..So please some examples...
Regards
Somasundaram G
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jul 10, 2008, 12:13 PM EDT
You can select the set mask property of the mask textbox and from the mask description you can select the time format.
if you want it to do by coding you can refer the following code:
private void txtAlerts_KeyPress(object sender, KeyPressEventArgs e)
{
System.Text.RegularExpressions.Regex rtime = new System.Text.RegularExpressions.Regex(@"[0-2][0-9]\:[0-6][0-9]");
if (!rtime.IsMatch(txtAlerts.Text))
{
MessageBox.Show("Please provide the time in hh:mm format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Note: 'txtAlerts'is the id of my textbox.
soma sundaram5 reputationPosted Jul 10, 2008, 10:16 PM EDT
Hi Niradhip,
Thankyou very much...now its working fine...
But i am using Two Maskedboxes..one maskedbox is minimum Time (06:00:00) and another one masked box Maximum Time ie(30:00:00)...So i need, When i press the key only it should take range validation for eg ( min time is 06:00:00) and Max time (30:00:00) So how to do..any Regular Expression is their.Please tell me..
Regards
Somasundaram G
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jul 11, 2008, 4:05 PM EDT
You can modify the code in onkeypress event. Modify the value inside
System.Text.RegularExpressions.Regex to suit your need
System.Text.RegularExpressions.Regex rtime = new System.Text.RegularExpressions.Regex(@"[0-2][0-9]\:[0-6][0-9]");
soma sundaram5 reputationPosted Jul 17, 2008, 2:34 AM EDT
Hi Nirpa,
thanks..But i have tried this (@"[0-2][0-9]\:[0-6][0-9]")
but i am getting upto 29:59:59 But i need Maximum time is 30:00:00
So please help me...
Regards
Somasundaram
Khan Abrar AhmedRank #778 · 3K reputationPosted Jun 11, 2014, 11:36 PM EDT
(@"[0-3][0-9]\:[0-6][0-9]\:[0-6][0-9]") this wil match till 39:59:59 or 30:00:00