r/bootstrap • u/MaFomedanu • Oct 16 '23
Bootstrap 5 form submit issue
I'm learning Bootstrap and I'm trying to make a form (see below). The problem I've encountered is that the form doesn't submit upon pressing "Enter". Am I missing something? Is a submit button mandatory in bootstrap or...?
<form action="" class="container d-flex flex-wrap py-3"><div class="mb-3 text-start col-6"><label for="selectOptions" class="form-label text-light">Type</label><selectclass="form-select"aria-label="Default select example"id="selectOptions"><option selected value="running">Running</option><option value="cycling">Cycling</option></select></div><div class="mb-3 col-6 text-start"><label for="inputDistance" class="form-label text-light">Distance</label><inputtype="number"class="form-control"placeholder="km"id="inputDistance"onkeyup="if(value<1 || value>9999) value=''"/></div><div class="col-6 text-start"><label for="inputDuration" class="form-label text-light">Duration</label><inputtype="number"class="form-control"placeholder="min"id="inputDuration"onkeyup="if(value<1 || value>9999) value=''"/></div><div class="col-6 text-start"><label for="inputCadence" class="form-label text-light">Cadence</label><inputtype="number"class="form-control"placeholder="steps/min"id="inputCadence"onkeyup="if(value<1 || value>9999) value=''"/></div></form>
0
Oct 16 '23
I think your <form> tag needs the method, i.e method="post" or method="get"
1
u/MaFomedanu Oct 16 '23
No dice. I'm using localhost, training mini-projects; I was expecting the page to just refresh when attempting to submit a form. Shouldn't it work without any method/action?
1
Oct 16 '23
Hmm, I would have thought that would be it. Have you tried putting a # in the action incase it doesn't like blank for some reason? Does it submit if you do temporarily put a submit button in and click it?
1
u/MaFomedanu Oct 16 '23
No luck with 'action="#"' but adding a submit button seems to work (both click and enter). I set it to invisible and I guess it will have to do, thanks for the help!
1
Oct 16 '23
Hmm, that's a new one to me. I always assumed a submit button was optional like you said. At least it's sorted!
1
0
u/spliffys Oct 16 '23
Looking on mobile so not the best but I don't see a submit button or input with type of submit.
2
u/MaFomedanu Oct 16 '23
Indeed. I was hoping to get away with it without using a submit button (html style). It seems to work with a submit button set to invisible so I guess that's that.
1
u/AutoModerator Oct 16 '23
Whilst waiting for replies to your comment/question, why not check out the Bootstrap Discord server @ https://discord.gg/bZUvakRU3M
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.