keypress event

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

keypress event

Praveena
Hi,

I would like to show an alert each time user presses any key on the keyboard.

xxforms:text specifies the key you want to listen to, how do we specify for more than one key?

For example xxforms:text="a s d f" works, but what if there are more than 10 keys or all the alphabets?

Thanks
Praveena
Reply | Threaded
Open this post in threaded view
|

Re: keypress event

Alessandro  Vernet
Administrator
Hi Praveena,

Then you would have to mention all the keys/symbols you want to listen to. But may I ask what the use case is for listening to so many characters?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: keypress event

Praveena
Hi Alex,

I have a text box which should allow the user to enter only alphabets. Validations have been written using the constraint attribute. But for the validation to work, user has to enter text in the control and then tab out which displays error message.

My requirement is to restrict the user to enter numbers. Is there a way this can be done.

Regards
Praveena
Reply | Threaded
Open this post in threaded view
|

Re: keypress event

Alessandro  Vernet
Administrator
Hi Praveena,

If you want the validation to be done as users type in the field, instead of when they move to the next field, add an incremental="true" on the control. If you want to prevent the characters from even showing (which personally, I don't like very much), use a jQuery plugin, like jquery.alphanum.

https://github.com/KevinSheedy/jquery.alphanum

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet