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 7434955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:58:41+00:00 2026-05-29T09:58:41+00:00

I have lots of forms in my MVC3 application that require the user to

  • 0

I have lots of forms in my MVC3 application that require the user to input dates.

The requirement of the date given could be one of many cases, i.e a Date with a time, just a date, a date in the past, a date and time in the past, a date in the future, a date and time in the future etc…

So, at the moment I give the a different class depending in what is required. For example….

$("input.input-date-past").datepicker({ numberOfMonths: 1, showButtonPanel: true, maxDate: -0 });

…configures a date picker that restricts the users choice to date in the past only.

All this is working OK, but I was wondering if there was a better way.

I’m thinking that I could give the view model properties an attribute that would define what type of input was required. i.e

[Required]
[PastDate]
public DateTime SomeDateFromThePast { get; set; }

[Required]
[FutureDate]
public DateTime SomeDateFromTheFuture { get; set; }

[Required]
[FutureDateTime] // Requires a time to be given i.e "01/01/2012 09:00"
public DateTime SomeDateTimeFromTheFuture { get; set; }

etc..

Then in an Shared/EditorTemplate with @model System.DateTime, which will interrogate the attributes given to the property and set the class of the as required.

Does that sound OK? Or does it stink?

If OK, how do you interrogate the attributes given to the property?

If it stinks, any other suggestions?

Many thanks,

ETFairfax.

  • 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-29T09:58:43+00:00Added an answer on May 29, 2026 at 9:58 am

    You can write your own hooks into ASP.NET MVC’s unobtrusive validation to write to data- attributes.

    This tutorial should get you started.

    http://www.codeproject.com/Articles/275056/Custom-Client-Side-Validation-in-ASP-NET-MVC3

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

Sidebar

Related Questions

I have a fairly complex view that has multiple forms, lots of validations on
I have an issue with a Windows Forms application that I am creating. The
I have a B2B we app having lots of forms taking input from registered
We have a web application (it is a game) with lots of various forms
I have a page with lots of forms on it and every form has
I have multiple forms for lots of products on my page and want to
I have a web application which is used by lots of non-technical users. I
So I currently have an application that is fairly complex with large-scale animations and
We have an application with multiple subsystems running in different threads (ie one thread
I have a MVC 3 Razor web application that needs to allow creating 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.