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:-
when type in text box, want change this:-
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
Post a Comment