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?
CodePudding user response:
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
}