Created
February 2, 2022 22:21
Revisions
-
David Johnson created this gist
Feb 2, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ window.onload = () => { /* Custom jquery-validation handling for check boxes must equal true Decorate C# model bool properties with [Range(typeof(bool), 'true', 'true', ErrorMessage = 'Add your error message')] to make their corresponding checkbox validate to 'must equal true' */ var defaultRangeValidator = $.validator.methods.range; $.validator.methods.range = function (value, element, param) { if (element.type === 'checkbox') { // if it's a checkbox return true if it is checked return element.checked; } else { // otherwise run the default validation function return defaultRangeValidator.call(this, value, element, param); } } };