diff --git a/curriculum/challenges/english/blocks/review-form-validation-with-javascript/6723ce555ff2dfc0cc04b69a.md b/curriculum/challenges/english/blocks/review-form-validation-with-javascript/6723ce555ff2dfc0cc04b69a.md index ab1bbf588cb..11adc408e11 100644 --- a/curriculum/challenges/english/blocks/review-form-validation-with-javascript/6723ce555ff2dfc0cc04b69a.md +++ b/curriculum/challenges/english/blocks/review-form-validation-with-javascript/6723ce555ff2dfc0cc04b69a.md @@ -5,71 +5,138 @@ challengeType: 31 dashedName: review-form-validation-with-javascript --- -# --description-- +# --interactive-- ## Validating Forms with JavaScript - **Constraint Validation API**: Certain HTML elements, such as the `textarea` and `input` elements, expose a constraint validation API. This API allows you to assert that the user's provided value for that element passes any HTML-level validation you have written, such as minimum length or pattern matching. - **`checkValidity()` method**: This method returns `true` if the element matches all HTML validation (based on its attributes), and `false` if it fails. -```js -const input = document.querySelector("input"); +:::interactive_editor -input.addEventListener("input", (e) => { - if (!e.target.checkValidity()) { - e.target.setCustomValidity("You must use a .com email.") - } -}) +```html +
+ + ``` +::: + - **`reportValidity()` Method**: This method tells the browser that the `input` is invalid. -```js -const input = document.querySelector("input"); +:::interactive_editor -input.addEventListener("input", (e) => { - if (!e.target.checkValidity()) { - e.target.reportValidity(); - } -}) +```html + + + ``` +::: + - **`validity` Property**: This property is used to get or set the validity state of form controls (like ``, `