0

I am using JSF, RichFaces and JavaScript. I change the value of an input field by JavaScript and after such a change, I want to trigger an event. My first try was to use this code:

<t:inputText id="info" value="#{controller.state}" onchange="adaptUserInterface();" />

Unfortunately 'onchange' didn't get triggered. How to solve this issue?

2
  • You can use this: zurb.com/playground/jquery-text-change-custom-event Commented Feb 11, 2013 at 9:54
  • You want to call a js function on text change ? know that the change event will be called when your input will loose its focus (click outside it for example) Commented Feb 11, 2013 at 9:58

2 Answers 2

1

Use onBlur. That should be enough for what you want.

Sign up to request clarification or add additional context in comments.

Comments

0

You can use onKeyup for changes and onPaste and onInput for pasted content in Textfields.

(function() {
    var info = document.getElementById('info');
    info.addEventListener('keyUp', function(){ adaptUserInterface(info.value)} );
    info.addEventListener('paste', function(){ adaptUserInterface(info.value)} );
    info.addEventListener('input', function(){ adaptUserInterface(info.value)} );
})();

function adaptUserInterface(value){  
  console.log(value);
}

DEMO HERE

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.