html - Trigger an event on changing value in an input using JAVASCRIPT -


i want trigger function changes state of button in webpage. input looks this:-

enter image description here

when type in text box, want change this:-

enter image description here

notice call button getting activated. using onblur method listen changes, not happen dynamically. enter in box, , click outside. point when onblur executes.
how call onblur method user changes value in box?
here javascript code using

function togglecallbutton() {     if (document.getelementbyid('dialarea').value == '') {         document.getelementbyid('callbutton').classlist                 .add('input-group-addon-disabled');         document.getelementbyid('callbutton').classlist                 .remove('input-group-addon-active');     } else {         document.getelementbyid('callbutton').classlist                 .remove('input-group-addon-disabled');         document.getelementbyid('callbutton').classlist                 .add('input-group-addon-active');     } } 

have tried this?

<input type="text" onchange="togglecallbutton();"/> 

edit:

<body>     <div>         <input id="dialarea" type="text" onkeyup="togglecallbutton();" />         <div id="callbutton">call button</div>     </div> </body> 

css

.input-group-addon-disabled{     opacity: 0.5; }  .input-group-addon-active{     opacity: 1; } 

javascript

function togglecallbutton() {     if (document.getelementbyid('dialarea').value == '') {         document.getelementbyid('callbutton').classlist.add('input-group-    addon-disabled');         document.getelementbyid('callbutton').classlist.remove('input-group-addon-active');     } else {         document.getelementbyid('callbutton').classlist.remove('input-group-addon-disabled');         document.getelementbyid('callbutton').classlist.add('input-group-addon-active');     } } window.onload = togglecallbutton; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -