Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ValidityState docs #26431

Merged
merged 28 commits into from
Jul 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c873204
Update ValidityState docs
teoli2003 Apr 26, 2023
07a687e
Test
teoli2003 Apr 26, 2023
98edd80
Rename part1
teoli2003 Apr 26, 2023
cd1e899
Rename part2
teoli2003 Apr 26, 2023
a3918fb
Fix flaw
teoli2003 Apr 26, 2023
f242896
Fix flaw
teoli2003 Apr 26, 2023
c0a4474
Merge branch 'main' into validitystate
queengooborg May 20, 2023
999d073
Merge branch 'main' into validitystate
teoli2003 Dec 20, 2023
0f85569
Update files/en-us/web/api/validitystate/valid/index.md
teoli2003 Dec 20, 2023
3e67113
Update files/en-us/web/api/validitystate/valid/index.md
teoli2003 Dec 20, 2023
cc50680
Update files/en-us/web/api/validitystate/valid/index.md
teoli2003 Dec 20, 2023
e44456c
Update files/en-us/web/api/validitystate/customerror/index.md
teoli2003 Dec 20, 2023
c14e74c
Update files/en-us/web/api/validitystate/customerror/index.md
teoli2003 Dec 20, 2023
0d49694
Merge branch 'validitystate' of github.com:teoli2003/content into val…
teoli2003 Dec 20, 2023
5ff1189
Add labels to input boxes
teoli2003 Dec 20, 2023
4db37a7
more
teoli2003 Dec 21, 2023
8eaf6fb
Merge branch 'main' into validitystate
estelle Mar 21, 2024
91f5e03
Merge branch 'main' into validitystate
bsmth Apr 10, 2024
861a2c3
Merge branch 'main' into validitystate
bsmth May 6, 2024
efcae61
Merge branch 'main' into validitystate
bsmth Jun 21, 2024
1c437ba
Merge branch 'main' into validitystate
bsmth Jul 2, 2024
94ee941
feat(api): reportValidity and setCustomValidity example
bsmth Jul 15, 2024
96a188a
feat(api): reportValidity and setCustomValidity example
bsmth Jul 15, 2024
79640e9
feat(api): reportValidity and setCustomValidity example
bsmth Jul 15, 2024
bdcd3f5
feat(api): reportValidity and setCustomValidity example
bsmth Jul 15, 2024
974d242
Merge branch 'main' into validitystate
bsmth Jul 15, 2024
19aa740
feat(api): reportValidity and setCustomValidity example
bsmth Jul 15, 2024
315c81d
feat(api): ValidityState examples
bsmth Jul 15, 2024
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
Prev Previous commit
Next Next commit
feat(api): reportValidity and setCustomValidity example
  • Loading branch information
bsmth committed Jul 15, 2024
commit 79640e9df7ebfe7cf8df9c38b61afea1ba76176d
7 changes: 4 additions & 3 deletions files/en-us/web/api/validitystate/customerror/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ A boolean that is `true` if a custom error message has been set to a non-empty s
In this example, `setCustomValidity` sets a custom error message when a form submission contains invalid user input.
Click the "Check input" button calls the `reportValidity` function, displaying a validation message if a user entered values does not match the [form control's constraints](/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process).
For example, if you enter the text "good" and try to validate the form, the field is marked invalid until the custom error message is cleared (set to an empty string).
When the value in the form control is invalid, even if there is not custom error, the widget will have a red outline.
For comparison, there is a [`minlength`](/en-US/docs/Web/HTML/Attributes/minlength) attribute which allows us to demonstrate the [`tooShort` validity state](/en-US/docs/Web/API/ValidityState/tooShort) when there is only one character entered.
When the value in the form control is invalid, even if there is no custom error, the input will have a red outline.

#### HTML

Expand Down Expand Up @@ -67,8 +68,8 @@ function log(text) {
}

const check = (input) => {
// For the exact string 'good', set a custom validity message
if (input.value === "good") {
// Handle cases where input is too vague
if (input.value == "good" || input.value == "fine") {
input.setCustomValidity(`"${input.value}" is not a feeling.`);
} else {
// An empty string resets the custom validity state
Expand Down