From 60f0a8716d1edda713e7a7388078c01761a8153f Mon Sep 17 00:00:00 2001 From: Jonathan Snell Date: Fri, 4 Oct 2013 18:05:54 +0100 Subject: [PATCH] make validatr conform to the html5 spec when form elements are disabled --- src/js/validatr.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/js/validatr.js b/src/js/validatr.js index 805355f..6b90599 100644 --- a/src/js/validatr.js +++ b/src/js/validatr.js @@ -785,6 +785,19 @@ message: '' }; + if ($element.prop('disabled')) { + check.disabled = true; + } else { + $element.parentsUntil('form', 'fieldset').each(function() { + var $this = $(this); + check.disabled = $this.prop('disabled') && ($element.closest($this.children('label:first-of-type')).length == 0); + }); + } + if (check.disabled) { + $element.trigger('valid'); + return true; + } + if (Support.inputtypes[type]) { check.valid = element.validity.valid; check.message = element.validationMessage;