Skip Navigation

[Resolved] I need to add an attribute (onkeypress) to a text input.

This support ticket is created 3 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Jamal 3 years, 10 months ago.

Assisted by: Jamal.

Author
Posts
#1652167

Hi guys.
I need to add an attribute (onkeypress) to a text input.

Ex:
[cred_field field='post_title' onkeypress="somenteNumeros()"]

#1652665

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

Currently, there is no way to add such attributes to the generated forms fields. But we can use a custom Javascript code on the form to get the same results, by using the "keypress" event from jQuery. Check this sample code, based on the field name:

$( "input[name=post_title]" ).keypress(function() {
  console.log( "Handler for .keypress() called." );
  // Here you can call your function 
  somenteNumeros()
});

More about the jQuery API here hidden link

I hope this helps. Let me know your feedback.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.