Prevent Form Submit On Enter Is Not Working - OutSystems

Community/Forums/QuestionsUserImage.jpgJohn JakeRank: #147767Prevent form submit on enter is not working187Views2CommentsSolvedQuestionTraining

I have a text input, this text input have a server action in the On Change Destination to do some stuff when the input value changes.

I want to prevent that the form is submitted if user presses enter in this input. So in the input element in Extended properties I add this:

onkeydown

"return event.key != 'Enter;"

But its not working, when the enter is pressed the form is submitted. Do you know why?

0024 Mar 2020Copy post link2021-10-26 09-17-56João DelgadoRank: #1008Solution

John Jake,

On your keydown event try to put the following code:

SyntaxEditor Code Snippet

"if (window.event.keyCode == 13 ) return false"

I tested and it should be enough to achieve what you are trying to do.

Best Regards,

João Delgado

1024 Mar 2020Copy comment link
UserImage.jpg1 reply07 Oct 2023Show threadHide threadUserImage.jpgHenrique ChigumaneRank: #18177

thanks, it worked for me!

0007 Oct 2023Copy comment link
Try OutSystems nowGenerate an App with AI Loading...

Từ khóa » Html Form Block Enter Submit