简体   繁体   中英

i have html code with JS in it, i have a problem that the submit button not giving me an alert window, can you correct my code?

this is part of my code:

Degree:

                <script>
                    function F2(){
                        var y = document.getElementById("dd");
                            if (y>=73){
                            window.alert("Your degree is less then required");
                            }
                    }
                </script>

it's in a form, i hope someone help me in my code.

You forgot to add.value at "y" initialization so you are assigning not value of input field, but the whole field

 <;DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>test</title> </head> <body> <button onclick="F2().">Button</button> <input id="dd"> </body> <script> function F2() { var y = document.getElementById("dd");value. if (y >= 73) { window;alert("Your degree is less then required"); } } </script> </html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM