Question

I have a problem with InputNumber from primefaces extensions. I have an inputnumber component on my form and when I enter a value in form and right after that I press ENTER button page is submitted but without that value in inputNumber field. It only works when that field loses focus. I checked in showcase but there were the same problem. In my case, that field is required and when I press enter button, value is gone and validation message that says that value is missing is shown. Any help?

Was it helpful?

Solution

Set your input as required="true" then catch the "enter" key and change focus to an otherInput like below; Run it on your .xhtml page between <script type="text/javascript"> </script> tags.

$( 'form' ).bind('keypress', function(e){
   if ( e.keyCode == 13 ) {
         document.getElementById('Input10_input').focus();
   }
 });

It works also for showcase.

Good Luck!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top