Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:15:09+00:00 2026-05-31T22:15:09+00:00

In my C#/MVC4/Razor Application I need to make sure that user enter not only

  • 0

In my C#/MVC4/Razor Application I need to make sure that user enter not only date, but also time. My Model is:

[Required]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy HH:mm}", ApplyFormatInEditMode = true)]
public DateTime Start { get; set; }

If user enters 02/03/2012, it will be converted to 02/03/2012 00:00.

I tried to implement custom ValidationAttribute, but I receive the value only after it is already converted to DateTime and I don’t know, if user entered only date or date with time (“00:00” value).

Is it possible to force user enter date and time?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:15:10+00:00Added an answer on May 31, 2026 at 10:15 pm

    You could write a custom model binder for the DateTime type which will take the DisplayFormat attribute format into account when binding the value. Here’s an example such binder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi My hosting Provider has support for MVC3 but not for MVC4. When I
I've got really used to developing views in MVC4 using Razor. But I have
I saw that ASP.Net MVC4 WebApi exposes services as a Rest ones. But what
I'm working on upgrading an application from MVC3 to MVC4 and noticed something that
Client side Validation and ValidationSummary is working fine for my project (MVC4 + Razor
I have an MVC4 web application In setting it up on IIS7.5 I added
If you create a new MVC4 web application with the Internet Application Project Template
I have been writing an application using ASP.Net MVC4, where the majority of the
(Using MVC4 VB EF4 MSSQL Razor) I created a Stored Procedure in the MS
I have an MVC 4 application that I'm localizing. All the built-in resourcing and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.