Skip to content

Commit

Permalink
Merge pull request #46 from markuspeter/main
Browse files Browse the repository at this point in the history
Fix required validator for inputs other than checkbox and radio
  • Loading branch information
haacked authored Jun 21, 2023
2 parents d6d4aff + 26ac977 commit f74388e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 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.

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aspnet-client-validation",
"version": "0.8.8",
"version": "0.8.9",
"description": "Enables ASP.NET MVC client-side validation, without jQuery!",
"main": "dist/aspnet-validation.js",
"style": "dist/aspnet-validation.css",
Expand Down
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 f74388e

Please sign in to comment.