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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Khan Abrar AhmedPosted Jun 12, 2014, 3:36 AM
(@"[0-3][0-9]\:[0-6][0-9]\:[0-6][0-9]") this wil match till 39:59:59 or 30:00:00
soma sundaramPosted Jul 17, 2008, 6:34 AM
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
Niradhip ChakrabortyPosted Jul 11, 2008, 8:05 PM
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 sundaramPosted Jul 11, 2008, 2:16 AM
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 ChakrabortyPosted Jul 10, 2008, 4:13 PM
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.