Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 05, 2007 05:14 PM by Nullable
Member
264 Points
67 Posts
Jan 05, 2007 01:57 PM|LINK
I have a few fields on a form which I'd like to check before they are updated into the database.
For date I use "comparevalidator" wih Operator = DataTypeCheck and Type=Date.
But this doesn't work for a time. I've tried it and I also read it on the msdn pages.
How can I check if the users enter a correct time in the format hh:mm ?
Thx in advance.
Contributor
3974 Points
740 Posts
Jan 05, 2007 05:14 PM|LINK
You could use regular expressions:
{
}
Dataconsult
Member
264 Points
67 Posts
How to validate a correct time?
Jan 05, 2007 01:57 PM|LINK
I have a few fields on a form which I'd like to check before they are updated into the database.
For date I use "comparevalidator" wih Operator = DataTypeCheck and Type=Date.
But this doesn't work for a time. I've tried it and I also read it on the msdn pages.
How can I check if the users enter a correct time in the format hh:mm ?
Thx in advance.
Nullable
Contributor
3974 Points
740 Posts
Re: How to validate a correct time?
Jan 05, 2007 05:14 PM|LINK
You could use regular expressions:
if (Regex.IsMatch(myTextBox.Text, @"^((\n[01]?\d)|(\n2[1234])):([0123456]?\d)")){
// it's good!!!}
else{
// it's not good!!!}
http://www.SingingEels.com/
Developer / Architect / Author