Skip to content
Advertisement

OnSubmit function not working for an input type= ‘submit’

I am making a quiz app using django and it’s my first ever work using django Everything else is working fine instead of one thing which is whenever i press the button to submit the answer, page simply reloads.

Here’s my html code:

JavaScript

Here’s the js code relevance to the button:

JavaScript

According to this script I must see an alert whenever i press the submit button but the page simply reload without showing any alert messages. I am new in working with django apps if there is something I’m missing please guide. ThankYou!

Advertisement

Answer

I think that you need to remove the action on the form as the form is required to submit it back to the server. And add the event to the input. There’s also a div missing. I don’t know what the pre-processing does, so I have just copied it. Something like

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement