JSFiddle - React, Tailwind, and code Playground
by Aravind Baskaran
HTML
<form data-bind="event: {submit: doWork}">
<input type="tel" data-bind="value: myInputValue, event: { keypress: myInputKeypress }" min="0" step="1" max="29" />
</form>
JavaScript
var viewModel = {
"myInputValue": ko.observable(),
"myInputKeypress": function () {
var keyCode = (event.which ? event.which : event.keyCode);
/*alert(keyCode);
if (keyCode === 13) {
//Do work here
return false;
}*/
return true;
},
"doWork": function(){
alert(this.myInputValue());
}
}
ko.applyBindings(viewModel);