• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

DateTime validator with full date AND time in C# .ASP environment.

This is in the C#.ASP environment.

I want to make sure any information entered into a textbox is a full datetime in this format:

2009-1-1 08:00:00
2009-01-01 08:00:00

(note the addition of zeros).

I don't know which validator to use or how to set the validator to accept only the above datetimes (I want to reject dates like '2009-01-01' because there is no time component).
  • 3
1 Solution
Rakesh JaiminiCommented:
try this
DateTime temp;
DateTime.TryParse(startDateTextBox.Text, out temp)
M3hcSSAuthor Commented:
I do not want to use the tryparse function because it requires me to explicetly make a dataconnection, dataset, and databind on a gridview. I was going down that path when I thought I could use the form validators to check the user's input.
Rakesh JaiminiCommented:
try using javascript
attach onblur event with textbox and use regex to validate the input
to attach onblur event check following link

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now