diff --git a/files/en-us/web/api/canvas_api/tutorial/applying_styles_and_colors/index.md b/files/en-us/web/api/canvas_api/tutorial/applying_styles_and_colors/index.md index a292ea3a4ab7b0b..0e3b7c9f5a0b734 100644 --- a/files/en-us/web/api/canvas_api/tutorial/applying_styles_and_colors/index.md +++ b/files/en-us/web/api/canvas_api/tutorial/applying_styles_and_colors/index.md @@ -392,10 +392,8 @@ function draw() { ctx.lineWidth = 10; // check input - if (document.getElementById("miterLimit").value.match(/\d+(\.\d+)?/)) { + if (document.getElementById("miterLimit").checkValidity()) { ctx.miterLimit = parseFloat(document.getElementById("miterLimit").value); - } else { - alert("Value must be a positive number"); } // Draw lines @@ -419,11 +417,9 @@ function draw() { Change the miterLimit by entering a new value below and clicking the redraw button.

-
- - - -
+ + + @@ -434,6 +430,9 @@ document.getElementById("miterLimit").value = document .getElementById("canvas") .getContext("2d").miterLimit; draw(); + +const redraw = document.getElementById("redraw"); +redraw.addEventListener("click", draw); ``` {{EmbedLiveSample("A_demo_of_the_miterLimit_property", "", "180")}}