JQuery Confirm onclick: false not working for checkbox or select

I am trying to disable validation before sending after an error occurs. The onfocusout handler works fine, but onclick does not work for a checkbox or select element.

As a quick example, I wrote the following. If you submit an empty form and then adjust the checkbox and select, they should not be checked immediately. You will see that text input is working correctly.

The selection seems to work sometimes, regardless of the onclick handler. He did an onclick check in safari, not in chrome.

Fiddle: http://jsfiddle.net/ebMdq/6/

<form id="myForm" action=""> Name: <input type="text" name="fname" /><br /> Do you Rawk? <input type="checkbox" name="rock" /><br /> choose color: <select id="color" name="color" class="required"> <option value="">Choose One</option> <option value="blue">blue</option> <option value="blue">red</option> </select><br /> <input type="submit" /> </form>​ $(function () { var validator = $("#myForm").validate({ onfocusout: false, onkeyup: false, onlclick: false, rules: { fname: "required", rock: "required", color: "required" }, messages: { fname: "Enter your firstname", rock: "you know you do", color: "pick one!", }, }); }); 
+4
source share
1 answer

Choices, radio and checkboxes have inconsistent event behavior across browsers.

change or onchange is used for radio / flags.

0
source

Source: https://habr.com/ru/post/1434320/


All Articles