Reputation: 10667
I have an HTML5 number input with a min of 0.01
and a step of any
. But for the user, the first "step" is 0.01, and subsequent steps include ".01".
I want to enforce a minimum value of 0.01 while allowing the user to step in whole numbers (i.e., 1, 2, 3, etc.).
How is this possible?
Upvotes: 3
Views: 700
Reputation: 48798
I think you're going to have to use JavaScript. With jQuery it would be:
$('input').on('change', function() {
var $this = $(this);
if ($this.val() < 0.01) {
$this.val('0.01');
}
});
Upvotes: 2