Skip to content Skip to sidebar Skip to footer

How To Specify Custom Invalid Condition In Jquery Validation Engine?

I have two select boxes each with some values I want to validate for condition that, if value Value 1 is greater than value in Value 2 then the error prompt should show and the for

Solution 1:

Yes. It can be done.. You don't have to use validation engine like that for this functionality..

I have simply used onSubmit event of form and required attribute in your dropdown.

Check this snippet. I have modified the code of your fiddle in here..

functiontestfunc() {
  var val1 = $('#value1select').val();
  var val2 = $('#value2select').val();
  if (val1 !== '' && val2 !== '') {
    if (parseFloat(val1) > parseFloat(val2)) {
      returntrue;
    } else {
      alert("ERROR PROMPT!")
      returnfalse;
    }
  }
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><formaction=''name="formid1"id="formid1"onSubmit="return testfunc()"><br /><br /><div><table><tr><td>Value 1</td><td><selectid="value1select"required ><optionvalue="">---Select---</option><optionvalue="-1">-1</option><optionvalue="-2">-2</option><optionvalue="-3">-3</option><optionvalue="-4">-4</option><optionvalue="-5">-5</option><optionvalue="-190">-190</option></select></td></tr><tr><td>Value 2</td><td><selectid="value2select"required><optionvalue="">---Select---</option><optionvalue="0">0</option><optionvalue="-1">-1</option><optionvalue="-2">-2</option><optionvalue="-3">-3</option><optionvalue="-4">-4</option><optionvalue="-5">-5</option></select></td></tr><tr><td><inputtype="submit"value="Submit" /></td></tr></table></div></form>

Post a Comment for "How To Specify Custom Invalid Condition In Jquery Validation Engine?"