When I press the enter key on p:inputText
field then automatically triggered p:commandButton
. This is not the behaviour I want.
How can I disable the automated triggering?
When I press the enter key on p:inputText
field then automatically triggered p:commandButton
. This is not the behaviour I want.
How can I disable the automated triggering?
You can disable this behaviour by return false in the
onkeypress
attribute on yourh:form
.13 is the key code corresponding to "Enter"
However, this snippet can break your
textarea
(you want users to be able to hit Enter to get a new line) so I would improve the above snippet and define a custom JS function..xhtml
.js