Enable button after entering at least 3 characters

Enable button after entering at least 3 characters

  

I have a search FIELD and search BUTTON.

I'd like to have the BUTTON disabled - UNTIL - the user enters at least 3 characters.

I am using the OnChange event to call a ScreenAction that checks the input length and enables/refresh the button. It works great - BUT - the lag of the OnChange is a problem as folks often type the search query and hit the enter key BEFORE the OnChange even fires.

Ideally, is there a way to have the ScreenAction module fire OnKeyPress instead of OnChange?


Correction, I edited my question ... I want to be able to call a ScreenAction (not a Logic module) "OnKeyPress" rather than OnChange that is built-in.

Solution

Hello Bruce,

You can use the Extended Properties section of a widget to add attributes to the element, like the OnKeyPress, OnKeyUp, OnClick, etc.

The value can be JavaScript.

Ex:

OnKeyUp

= "MyJSFunction();"

To call a ScreenAction, you can use the FakeNotifyWidget From Richwidgets.

But I would say that you can simply check in JavaScript if the input has 3 or more characters and enable/disable the button directly from the JavaScript.

Cheers

Solution

Hello Bruce,

How are you?
Did you solve the issue? Do you need more info or help?

Cheers

Eduardo Jauch wrote:

Hello Bruce,

How are you?
Did you solve the issue? Do you need more info or help?

Cheers

Thanks for following up - yes, the FakeNotifyWidget did the trick thanks!


Nice :)

Cheers.