Jquery Validation for Two Dropdown Boxes [duplicate]


This question already has an answer here:

<ul><li> <a href="/questions/241145/jquery-validate-plugin-how-to-create-a-simple-custom-rule" dir="ltr" rel="nofollow">jQuery Validate Plugin - How to create a simple custom rule?</a> <span class="question-originals-answer-count"> 7 answers </span> </li> </ul>

I have Two dropdown boxes, if i select 4 from first select box, the value of the second dropdown value must be less than the first dropdown. if it fails show a custom error message, like that.

<select name="t_dropdown" id="t_dropdown" class="form-control required"> <option value="">Select Value</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> <select name="p_dropdown" id="p_dropdown" class="form-control required"> <option value="">Select Value</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value=">6">>6</option> </select>

Please let me know, how to do it using jquery validations.


You can use <a href="http://jqueryvalidation.org/jQuery.validator.addMethod/" rel="nofollow">jQuery.validator.addMethod</a>-

$.validator.addMethod("matchValue", function (value, element) { if($('#t_dropdown').val()==4) { return value < 4; } else { return true; } }, 'Invalid Value');

<a href="http://jsfiddle.net/KrLkF/492/" rel="nofollow">Demo</a>


  • “Big” scrollbar for spinner
  • Is it safe to cast void pointer to char pointer pointer
  • How can i use Django smart select to filter ManyToManyField?
  • OpenCV Python: Draw minAreaRect ( RotatedRect not implemented)
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • Client side validation mvc dropdown
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Creating a DropDownList
  • npm 5.4.1 install/uninstall all failing
  • ListItem.Attributes.Add not working
  • Ajax calls do not work in IE unless you fiddle with security settings
  • Keep this build forever option - Jenkins
  • OpenGL 3.3 on Mac OSX El Capitan with LWJGL
  • Using $this when not in object context
  • Array.prototype.includes - not transformed with babel
  • Volley JsonObjectRequest send headers in GET Request
  • Accessing IRQ description array within a module and displaying action names
  • Running a C# exe file
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • How to show dropdown in excel using jrxml (jasper api)?
  • Build own AppleScript numerical error handling
  • Websockets service method fails during R startup
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • Google cloud sdk not working when python points python3
  • Is there a mandatory requirement to switch app.yaml?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • AngularJs get employee from factory
  • Load html files in TinyMce
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Getting Messege Twice Using IMvxMessenger
  • How does Linux kernel interrupt the application?
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal