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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:54:17+00:00 2026-06-09T21:54:17+00:00

I use 2 same inputs at search form. I want to control data typing.

  • 0

I use 2 same inputs at search form. I want to control data typing. For example, user enter time or price in any interval. Second value must be larger than first.
How to make user can not enter larger value to second field?

For date:

@Html.TextBox( "date1", string.Empty, new { @class = "dateClass", type_datepicker = "true", @id = "datepicker" } )
@Html.TextBox( "date2", string.Empty, new { @class = "dateClass", type_datepicker = "true", @id = "datepicker2" } )

and for price:

@Html.TextBox( "price1", string.Empty, new { @class = "priceClass" } )
@Html.TextBox( "price2", string.Empty, new { @class = "priceClass" } )

date1 and date2 are string, price1 and price2 are double. Sorry for my bad english..

  • 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-09T21:54:19+00:00Added an answer on June 9, 2026 at 9:54 pm

    You need to tweak this so it matches whatever your backend code is returning back

    You have a few options here, you can either validate when the user submits the form or when the user stops typing. At submit is pretty straight forward

    if ($('#second').val() > $('#first').val()){
          return false;
       }
    

    For comparing dates, check this out

    Or you can do it when user stops typing, thanks to this great answer you can do this

    $(document).ready(function(){
    var typingTimer;                //timer identifier
    var doneTypingInterval = 1000;  //time in ms, 1 second for example
    
     //on keyup, start the countdown
    $('#second').keyup(function(){
        typingTimer = setTimeout(doneTyping, doneTypingInterval);
     });
    
     //on keydown, clear the countdown
        $('#second').keydown(function(){
        clearTimeout(typingTimer);
      });
    
     //user is "finished typing," do something
      function doneTyping () {
         if ($('#second').val() > $('#first').val()){
          alert('cannot do that');        //take whatever action you need here
       }
      }
    });
    

    Also, for datepickers, if you are using jQuery UI datepicker, there is an option to specify disabling certain date ranges, so you can use that to disable anything earlier than the value of the first datepicker (but again all that is just client side checks, if this is crucial to your application you will have to do back-end checks as well in C# or whatever language you are using)

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

Sidebar

Related Questions

I want to use the same function if the user submit the #postcode-form or
Previously, I have an app that uses core data. I use same store url
I want to use the same ant script to do a build in either
I want to use the same style in many listviews. And in my style
I am planning to use the same XHTML5 file for data storage AND display.
I would like to have one input field, where user will input search data.
I have a form where a user inputs a word, when pressing the button
Hi I have the below example form <form id=search method=GET action=/results> <input type=text name=name>
The function search below searches for two inputs which have the same output under
I am trying to use same validation function for all my controls. But I

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.