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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:42:10+00:00 2026-06-14T23:42:10+00:00

I have two fields in my model CreateDateTo CreateDateFrom which renders like this <b>Start

  • 0

I have two fields in my model

  1. CreateDateTo
  2. CreateDateFrom

which renders like this

<b>Start Date</b>  @Html.EditorFor(model => model.AdvanceSearch.CreateDatefrom, new {  @class = "picker startDate" })

<b>End Date</b> @Html.EditorFor(model => model.AdvanceSearch.CreateDateto, new { @class = "picker endDate" })

I have a validation scenario that enddate should not be greater then start date, currently I am validating it by jquery

$.validator.addMethod("endDate", function (value, element) {
        var startDate = $('.startDate').val();
        return Date.parse(startDate) <= Date.parse(value);
    }, "* End date must be Equal/After start date");

I want to know that is there any way in MVC3 model validation to do this?

  • 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-06-14T23:42:12+00:00Added an answer on June 14, 2026 at 11:42 pm

    You need to create a custom validation against the model. You could put this in the controller after if(Model.IsValid)


    if(Model.End<Model.StartDate)
       ....
    

    But I would stick to javascript.
    It works on the clientside and does not hit the server.
    Unless you just need the added assurance.

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

Sidebar

Related Questions

I have a basic ActiveRecord model in which i have two fields that i
I have a model in which there are two fields, one characterized by the
I have a model that has two fields, which I will call first_name and
I have two fields which calculate a total, but I have a radio button
I have two fields that I'd like to match. (already done the validation functions
I have two models with slug fields: class Book(models.Model): name = models.CharField(max_length=200) slug =
I have two models in Django like follows(in pseudo code) class Medicine(db.Model): field_1 =
If I have two models like class Author(models.Model): name = models.CharField(max_length=100) title = models.CharField(max_length=3,
I have a subject model with two fields - name and level. I want
I have three models: System_Contact System Contact_list The Contact_List model has two fields: contact

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.