Skip to content

Commit

Permalink
Fix required validator for inputs other than checkbox and radio
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Peter committed Jun 21, 2023
1 parent d6d4aff commit aa5543a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/aspnet-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ var MvcValidationProviders = /** @class */ (function () {
this.required = function (value, element, params) {
// Handle single and multiple checkboxes/radio buttons.
var elementType = element.type.toLowerCase();
if (elementType === "checkbox" || elementType) {
if (elementType === "checkbox" || elementType === "radio") {
var allElementsOfThisName = Array.from(element.form.querySelectorAll("input[name='".concat(element.name, "'][type='").concat(elementType, "']")));
for (var _i = 0, allElementsOfThisName_1 = allElementsOfThisName; _i < allElementsOfThisName_1.length; _i++) {
var element_1 = allElementsOfThisName_1[_i];
Expand Down
2 changes: 1 addition & 1 deletion dist/aspnet-validation.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/aspnet-validation.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class MvcValidationProviders {
required: ValidationProvider = (value, element, params) => {
// Handle single and multiple checkboxes/radio buttons.
const elementType = element.type.toLowerCase();
if (elementType === "checkbox" || elementType) {
if (elementType === "checkbox" || elementType === "radio") {
const allElementsOfThisName = Array.from(element.form.querySelectorAll(`input[name='${element.name}'][type='${elementType}']`));
for (let element of allElementsOfThisName) {
if (element instanceof HTMLInputElement && element.checked === true) {
Expand Down

0 comments on commit aa5543a

Please sign in to comment.