Android : Limiting and/or automatically changing value for number input fields

on Tuesday, October 28, 2014


I am working on a minigolf app for Android, and I am using knockout foreach bindings to display 18 rows of input number fields where users can insert there numbers of hits they needed for each hole.


My first requirement is that I want those input fields to behave so that when the user enters "9", it should automatically change to 10 (because the rules for the minigolf say that if the user uses more than 8 hits, the hole should be counted as 10).


My second requirement is that it's possible to type in numbers higher than 10 at the moment. I have to specify that you can't type in numbers higher than 10 into the input fields.


Anyone who got any idea to solve my requirements?


This is my ko foreach:



<!-- ko foreach: rounds -->
<input class="input-block-level"
name="number"
type="number"
value=""
data-bind="value: hits,valueUpdate: 'keyup'"
maxlength="2"
min="1"
max="10"/>
<!-- /ko -->

0 comments:

Post a Comment