2
votes

I'm building a reactive form with Angular, I have obviously a type "submit" button. I have also other buttons elements . But I don't want these buttons to submit the form. How can I achieve that ? I thought without "type='submit'" attribute on button elements, the form wasn't submitted, but it seems not to be the case.

Thanks

2
type="button"AJT82
ok thanks, very easy. So most browsers without "type" attribute on buttons elements add "type=submit" by default, correct ?AntonBoarf
If your button is inside a form tag, it will by default be of type submit unless you explicitly tell it to be of type button :)AJT82
Can you share your codeSunil Kumar

2 Answers

5
votes

Submit button should be of type submit, and every other button that is not used to submit should be type button.

<button type="submit">This is for Submit</button>
<button type="button">Regular Degular button</button>

1
votes

Simple way to do this as:

type ="button"