+ 4
can someone tell me why this code take me to sololearn site instead of w3schools when I click the button?
<!DOCTYPE html> <html> <body> <form onsubmit="return validate()" method="post"> Number: <input type="text" name="num1" id="num1" /><br /> Repeat: <input type="text" name="num2" id="num2" /><br /> <a href="https://www.w3schools.com"> <input type="submit" value="Submit" /> </a> </form> <script> function validate() { var n1 = document.getElementById('num1'); var n2 = document.getElementById('num2'); if(n1.value !== '' && n2.value !== '') { if(n1.value == n2.value) { return true; } } // alert("The values should be equal and not blank"); return false; } </script> </body> </html>
10 Answers
+ 2
Glory S just add the action, just like I did in my answer
+ 8
or u could do it say target=â_blankâ
+ 4
youâr welcom Glory S
+ 3
Takes you to sololearn because you donât have an action in your form. The href you have has absolutely nothing to do with the form. Itâs just a link between your inputs and submit button. For the form to send to w3schools, you need:
<form onsubmit="return validate()" method="post" action=âhttps://www.w3schools.comâ>
+ 3
hey Glory S take a look at this might help you it has what you need to go to w3schools
https://code.sololearn.com/W2SwknROZXuE/?ref=app
+ 2
Also, when a form doesnât have the action included, itâs automatically submitted to itself, aka the url itâs at. Thatâs why if the form is at sololearn, itâll be submitted to sololearn.
+ 2
Mike could you please rewrite this code for me and make it go to w3schools.com when clicked? Thanks
+ 2
How?
+ 2
Thanks
+ 2
Thanks bro