Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm working on a custom field that will store a string. The text will have a custom formatter applied to it that will manipulate the structure of the string (adding dashes in the right places). I have a javascript that will apply those changes in the field's input textbox when creating a new content type with the custom field, but I can't figure out how to fire the javascript when the user enters the text. Can it be done and if so can anyone point me in the right direction?

share|improve this question
show us your code – Ayesh K Apr 9 at 20:39

2 Answers

You probably want to use Drupal behaviors which is a wrapper of sorts for JQuery. With JQuery you can make it so that everytime your textfield gets edited your Javascript code gets executed. Behaviors/JQuery is a big subject and will take time if you're not familiar. You can start here

The Drupal JavaScript API

JQuery tutorials

share|improve this answer
Thanks. I'll check this out. – Robbert Apr 10 at 16:05

1.With the help of onblur() function,you can trigger the written js. 2.onblur() function helps you in calling a js once the text is entered in the input field and the user press ENTER after entering the text.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.