G
G
Genri_Rus2020-04-23 00:19:37
JavaScript
Genri_Rus, 2020-04-23 00:19:37

How to prevent a submit button from responding to enter?

In general, here is an example: https://codepen.io/Genri_Rus/pen/XWmpKaX

If I click on a button with the submit type, then I get an input field
The problem is that if I (after clicking on the button) click enter, then my input is hidden and so on in a circle

On the desktop version, the input is not hidden, but in the mobile version I need to hide the input and leave only the button

How can I prevent a button with the submit type from responding to enter ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2020-04-23
@Genri_Rus

You are confusing terms, click, click and FIG you will understand what you want. When will writers start reading? :)
Each sentence is a piece of thought. Guess what he wants.
You described the problems without specifying what is really needed. Only references to other versions not shown here.
Do you have a problem with enter or a problem with blinking input? If so, what should be its behavior? Clicked on the button, input opened, pressed enter .... and what is expected (input disappeared / did not disappear)?

R
Rsa97, 2020-04-23
@Rsa97

Why are you giving the button a submit type if you immediately block it with preventDefault and don't want it to respond to Enter?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question