DateTime multiple language validation support (C#)

  • Thread starter Thread starter bredal Jensen
  • Start date Start date
B

bredal Jensen

I need to validate a DateTime field regardless of the
language my application is runnining in.
I have a textbox field where users can enter the
date like this:

02-03-2004 10:58:40 ----> meaning
(March the 3rd 2004 10:58:40 AM).


Any help will be great.

Thanks
Jensen
 
Hello Bredal,
bredal Jensen said:
I need to validate a DateTime field regardless of the
language my application is runnining in.
I have a textbox field where users can enter the
date like this:

02-03-2004 10:58:40 ----> meaning
(March the 3rd 2004 10:58:40 AM).


Any help will be great.
Work with regular expressions...look at this site..you will find the right
syntax..

http://www.regexlib.com/Search.aspx

mfg simon g.
 
The regular expression shown on the site are amazingly powerfull. I'm not
used to perl and awk and stuff and i think bringing this concept to the
windows world is a very
good move.

Is there a good way of patching the following sequence of caracters in a
string without too much trouble?

^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])
(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:
(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3
579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(
?:(?:1[6-9]|[2-9]\d)?\d{2}))($|
(?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(
[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
 
I have an alternative solution. I wrote a product that includes date and
time controls along with validators for them. All respect the CultureInfo
object of the page. Its called "Peter's Date Package"
http://www.peterblum.com/datecontrols/home.aspx. Instead of combining the
date and time into one textbox, I give you separate textboxes. That way, the
user interface is easier on the user. Each text box has its own syntax. The
DateTextBox has a popup calendar. The TimeOfDayTextBox has spinners to
change hours and minutes. Yet, the two can be connected so you set and get
one DateTime object value.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
Back
Top