html JS : Submit button doesn't work on enter

M4DM4X

Elite Member
Joined
Jan 21, 2015
Messages
2,911
Reaction score
1,753
Hi guys,
The form below is working fine when you click on submit with the mouse, but not when you click with the keyboard Enter key.

I found a solution on stackoverflow but I don't know to implement it, my knowledge in this field is too limited : https://stackoverflow.com/questions/20484738/submit-form-on-enter-key-with-javascript

Could you please help me modify the script so it accepts the 2 ways (keyboard+mouse) thanks a lot
Cheers

The code : https://pastebin.com/mEjgj6m9
(sorry I can't paste it here it doesnt seem to work even with the CODE tag)
 
use the solution but in the if statement you have to call the form to be submitted. or just dont sweat the small stuff.
 
i looked at your code. replace the button tag with <input type="submit" ect > not type="button". button isnt a type. you wont need js for it to click enter.
 
Thanks Twitchpro for your help.
I tried to replace the button tag by submit but it doesn't work, enter key still doesn't operate.
Concerning the stackoverflow I tried implementing it in my code but with no success, I don't know exactly where to put their code so I tried many places without any success.
 
Back
Top