From 7fea728b0d892b15d9507b3e9986096e0fa5a07f Mon Sep 17 00:00:00 2001 From: getsnoopy Date: Sun, 29 Sep 2024 14:41:54 -0500 Subject: [PATCH] Clean up constraint_validation/index.md There were quite a few issues with semantics and coding conventions in the file, so this commit fixes them to improve clarity. --- .../web/html/constraint_validation/index.md | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/files/en-us/web/html/constraint_validation/index.md b/files/en-us/web/html/constraint_validation/index.md index 0f878d6fd399127..d4917cd1bf90a6e 100644 --- a/files/en-us/web/html/constraint_validation/index.md +++ b/files/en-us/web/html/constraint_validation/index.md @@ -302,10 +302,10 @@ As an example, we will add a script checking the constraint validation for this ```html
- - - - + + + + ``` This displays: @@ -393,20 +393,20 @@ The JavaScript reads the file selected, uses the `File.size()` method to get its ```js function checkFileSize() { - const FS = document.getElementById("FS"); - const files = FS.files; + const fs = document.getElementById("fs"); + const files = fs.files; // If there is (at least) one file selected if (files.length > 0) { - if (files[0].size > 75 * 1024) { + if (files[0].size > 75 * 1000) { // Check the constraint - FS.setCustomValidity("The selected file must not be larger than 75 kB"); - FS.reportValidity(); + fs.setCustomValidity("The selected file must not be larger than 75 kB"); + fs.reportValidity(); return; } } // No custom constraint violation - FS.setCustomValidity(""); + fs.setCustomValidity(""); } ``` @@ -414,7 +414,7 @@ Finally, we hook the method with the correct event: ```js window.onload = () => { - document.getElementById("FS").onchange = checkFileSize; + document.getElementById("fs").onchange = checkFileSize; }; ```