vendor/assets/javascripts/webshims/shims/form-validators.js in webshims-rails-1.14.1 vs vendor/assets/javascripts/webshims/shims/form-validators.js in webshims-rails-1.14.3
- old
+ new
@@ -180,20 +180,31 @@
}
return message;
};
var testValidityRules = webshims.refreshCustomValidityRules;
- if(typeof document.activeElement != 'unknown'){
- $('body').on('click', function(e){
- if(e.target.type == 'submit'){
- var activeElement = document.activeElement;
- if(activeElement != e.target && $.data(activeElement, 'webshimsswitchvalidityclass')){
- $(activeElement).trigger('updatevalidation.webshims');
+ $('body').on('click', function(e){
+ if(e.target.type == 'submit' && !e.isDefaultPrevented()){
+ var activeElement, i, len;
+ var elements = $(e.target).jProp('form').prop('elements') || [];
+ try {
+ activeElement = document.activeElement;
+ } catch(e){}
+
+ for(i = 0, len = elements.length; i < len; i++){
+ if($.data(elements[i], 'customMismatchedRule')){
+ if(activeElement == elements[i]){
+ $(elements[i]).trigger('updatevalidation.webshims');
+ } else {
+ testValidityRules(elements[i]);
+ }
}
}
- });
- }
+
+ }
+ });
+
webshims.ready('forms form-validation', function(){
$.propHooks.setCustomValidity = {
get: function(elem){