744
Views
2
Comments
Allowing Enter Key in Input

Hi Outsystems,


I have this regex in extended properties:

onkeyup: 

"this.value=this.value.replace(/[^a-zA-Z0-9 /-?:().,'+]/g,'')"

and I want to allow the Enter key as well.

Any idea how can I accomplish this?


Regards,


Pedro Santos

2021-06-02 20-50-04
Márcio Carvalho

Hello Pedro, you can use the event on keyPressed like this. You can add an event listener waiting for the.

Or add to the events of your widget the onkeypress.

The event key code for entering is 13.

onkeypress
   function enterKeyPressed(event) {
      if (event.keyCode == 13) {
         console.log("Enter key is pressed");
         return true;
      } else {
         return false;
      }
   }

Look at this example

https://www.tutorialspoint.com/enter-key-press-event-in-javascript

Kind regards,

Márcio

2024-07-15 18-46-51
Franciel Oliveira

Hi Pedro,

1. Create a form

2. Put input field and button into it.

3. Set the "Is Form Default" to Yes.

Now when you press enter de default button will be called.

Best regards.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.