@@ -36,6 +36,7 @@ console.log(sum(2)(3)); // Outputs 5
3636<html >
3737
3838<head >
39+ <title >JavaScript File Upload Example</title >
3940 <script type =" text/javascript" >
4041 function showFileSize () {
4142 var input, file, extension;
@@ -84,34 +85,20 @@ File Extension: jpg
8485 var captcha;
8586
8687 function generateCaptcha () {
87- var a = Math .floor (Math .random () * 10 );
88- var b = Math .floor (Math .random () * 10 );
89- var c = Math .floor (Math .random () * 10 );
90- var d = Math .floor (Math .random () * 10 );
91-
92- captcha = a .toString () + b .toString () + c .toString () + d .toString ();
88+ captcha = Math .floor (Math .random () * 1000000 );
9389 document .getElementById (" captcha" ).value = captcha;
9490 }
95-
96- function check () {
97- var input = document .getElementById (" inputText" ).value ;
98-
99- if (input == captcha) {
100- alert (" Valid Captcha" );
101- } else {
102- alert (" Invalid Captcha" );
103- }
104- }
10591 </script >
92+
10693 <body onload =" generateCaptcha()" >
10794 <input type =" text" id =" captcha" disabled /><br /><br />
108- <input type =" text" id =" inputText" /><br /><br />
10995 <button onclick =" generateCaptcha()" >Refresh</button >
110- <button onclick =" check()" >Submit</button >
11196 </body >
11297</html >
11398```
11499
100+ ** ⚝ ; [ Try this example on CodeSandbox] ( https://codesandbox.io/s/js-cp-captcha-mzyi2n?file=/index.html ) **
101+
115102<div align =" right " >
116103 <b><a href="#">↥ back to top</a></b>
117104</div >
0 commit comments