Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public override void AddValidation(ClientModelValidationContext context)
throw new ArgumentNullException(nameof(context));
}

// ASP.NET Core marks bool with RequiredAttribute. Don't add the HTML5 required attribute for bool
// as it would cause unchecked checkboxes to block form submission in the browser.
// This matches the behavior of the built-in client-side validation.
if (context.ModelMetadata.ModelType == typeof(bool))
{
return;
}

MergeAttribute(context.Attributes, "required", "");
MergeErrorMessageTitle(context);
}
Expand Down