PrimeFaces disable submit on pressing enter key

前端 未结 6 1081
太阳男子
太阳男子 2021-01-19 07:51

PrimeFaces disable submit on pressing enter key.

I’m, running PrimeFaces 5.1 running on WildFly 8.2 Final.

I have dialog, with two inputNumbers and two butt

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-19 08:18

    I think you use JavaScript to capture the enter key press and do nothing.

    
    

    Ref: https://stackoverflow.com/a/5486046/201891

    return false; cancels an event across browsers if called at the end of an event handler attribute in the HTML. This behaviour is not formally specified anywhere as far as I know.

    Ref: https://stackoverflow.com/a/1648854/201891

    Update

    It sounds like you want to disable the Enter key only when focus is in a particular field. You can write a Javascript method for that too and bind it to onkeypress. Write a Javascript method something like "if the enter key was pressed and the focus is in this field, return false; otherwise, return true".

提交回复
热议问题