Issue
I have a Django form where I need to include buttons to make certains actions, like fill various fields, I'm doing this with javascript scripts. The problem comes when I click that button, the form validates, like if I'm submiting the form. Are there any ways to prevent this?
Solution
Yeah, you can easily prevent submitting the form with js.
Ex:
<button onclick="validate(event)"> Test </button>
js file:
const validate = (event) => {
event.preventDefault();
//do stuff
}
Answered By - misterbobot
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.