Skip to content

Commit

Permalink
Merge pull request cferdinandi#14 from cferdinandi/development
Browse files Browse the repository at this point in the history
v1.0.4
  • Loading branch information
cferdinandi authored Jun 15, 2017
2 parents c8c83d1 + 80fc646 commit faa03c4
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 25 deletions.
8 changes: 5 additions & 3 deletions dist/js/validate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* validate v1.0.3: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* validate v1.0.4: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* (c) 2017 Chris Ferdinandi
* MIT License
* http://github.com/cferdinandi/validate
Expand Down Expand Up @@ -227,9 +227,10 @@

// If the field is a radio button and part of a group, error all and get the last item in the group
if (field.type === 'radio' && field.name) {
var group = field.form.querySelectorAll('[name="' + field.name + '"]');
var group = document.getElementsByName(field.name);
if (group.length > 0) {
for (var i = 0; i < group.length; i++) {
if (group[i].form !== field.form) continue; // Only check fields in current form
group[i].classList.add(localSettings.fieldClass);
}
field = group[group.length - 1];
Expand Down Expand Up @@ -300,9 +301,10 @@

// If the field is a radio button and part of a group, remove error from all and get the last item in the group
if (field.type === 'radio' && field.name) {
var group = field.form.querySelectorAll('[name="' + field.name + '"]');
var group = document.getElementsByName(field.name);
if (group.length > 0) {
for (var i = 0; i < group.length; i++) {
if (group[i].form !== field.form) continue; // Only check fields in current form
group[i].classList.remove(localSettings.fieldClass);
}
field = group[group.length - 1];
Expand Down
4 changes: 2 additions & 2 deletions dist/js/validate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions dist/js/validityState-polyfill.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* validate v1.0.3: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* validate v1.0.4: A lightweight form validation script that augments native HTML5 form validation elements and attributes.
* (c) 2017 Chris Ferdinandi
* MIT License
* http://github.com/cferdinandi/validate
Expand Down Expand Up @@ -28,6 +28,19 @@
var length = field.value.length;
var valid = true;

// If radio group, get selected field
if (field.type === 'radio' && field.name) {
var group = document.getElementsByName(field.name);
if (group.length > 0) {
for (var i = 0; i < group.length; i++) {
if (group[i].form === field.form && field.checked) {
field = group[i];
break;
}
}
}
}

// Run validity checks
var checkValidity = {
badInput: (isNum && length > 0 && !/[-+]?[0-9]/.test(field.value)), // value of a number field is not a number
Expand Down Expand Up @@ -61,13 +74,13 @@
};

// If the full set of ValidityState features aren't supported, polyfill
if (!supported()) {
// if (!supported()) {
Object.defineProperty(HTMLInputElement.prototype, 'validity', {
get: function ValidityState() {
return getValidityState(this);
},
configurable: true,
});
}
// }

})(window, document);
4 changes: 2 additions & 2 deletions dist/js/validityState-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit faa03c4

Please sign in to comment.