+ 1
My JavaScript function not working
Why is my onsubmit function not being called? Thank you for the help :) https://code.sololearn.com/Wt3dQCaFX8a8/?ref=app
10 odpowiedzi
- 1
you can't name the function submit because submit is a built-in javascript function
just change the name to something else and it will work.
+ 2
David Dolejší I followed your answer and did the below code but still not working. But when i change the function name, it works! How??
https://code.sololearn.com/WbLiVDKEl1w7/?ref=app
+ 2
David Dolejší oh wow thank you! Now i have more understanding on this topic 😃
0
Oh yeah thank you. What are the odds for this happening🤔 My first ever JavaScript function testing and i named it an already used name 😲
0
Shaurya Kushwaha i got another doubt, i want to make that function to not do anything after submitting. In my below code, the screen goes blank after submitting and i want to avoid that, how can I do that?
https://code.sololearn.com/WXvfEh2IaKp4/?ref=app
0
you can put event.preventDefault(); in the function to prevent from reloading.
In the submit type button it always reloads the page so event.preventDefault(); prevents from that.
function submit1(){
alert("submitted!");
event.preventDefault();
}
0
Shaurya Kushwaha thank you :)