fix(validator): use a checked attribute for required validation in checkboxes (#205)

This commit is contained in:
Woramat Ngamkham 2022-11-26 03:35:42 +07:00 committed by GitHub
parent 21cd3f1775
commit 2f2c28b13f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -40,7 +40,8 @@ const { hook = 'all', displayErrorMessages = false } = Astro.props;
const limit = element.getAttribute(attribute); const limit = element.getAttribute(attribute);
return `${attribute}:${limit}`; return `${attribute}:${limit}`;
}); });
const value = element.value; const value =
element.type === 'checkbox' ? (element.checked ? 'checked' : '') : element.value;
const errors = validate(value, validators); const errors = validate(value, validators);
// set element hasErrors // set element hasErrors