<div> <form> <ch5-textinput type="text" feedbackMode="submit" ondirty="alert(2)" value="initial value"> </ch5-textinput> <div> <input type="submit" id="submit" value="Submit" /> <button type="button" id="reset">reset</button> <button id="dirty">getDirty</button> </div> </form> </div>
var input = document.querySelector('ch5-textinput'); var submit = document.querySelector('#submit'); var reset = document.querySelector('#reset'); var dirty = document.querySelector('#dirty'); var form = document.querySelector('form'); form.onsubmit = function(e) { e.preventDefault(); } submit.addEventListener('click', function() { console.log(input.submit()); }); reset.addEventListener('click', function() { input.reset(); }) dirty.addEventListener('click', function() { console.log(input.getDirty()); })