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

Posted on 2010-01-08
Last Modified: 2012-05-08
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).
Question by:M3hcSS
    LVL 10

    Accepted Solution

    try this
    DateTime temp;
    DateTime.TryParse(startDateTextBox.Text, out temp)
    LVL 2

    Author Comment

    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.
    LVL 10

    Expert Comment

    by:Rakesh Jaimini
    try using javascript
    attach onblur event with textbox and use regex to validate the input
    to attach onblur event check following link
    LVL 10

    Expert Comment

    by:Rakesh Jaimini

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now