Laetis
Laetis

Reputation: 1357

input number in html that is not an integer

I have a div where I want the user to input a number that is between 0.05 and 0.5. I did it this way:

<input id="TS_dist" class="tableButton" type="number" maxlength="1" size="5" value="0.2" />

The problem is that when I am puting a value I cannot use the zero, it is not working, the . is not either. Only 1-9 numbers are accepted.

My browser is firefox.

Do you have any idea what I am doing wrong?

Thanks

Upvotes: 0

Views: 67

Answers (3)

user4890314
user4890314

Reputation:

add step=0.1on <input> field that will work

Upvotes: 0

Curtis
Curtis

Reputation: 103348

By default the value increases/decreases by 1. Add a step attribute to change this behaviour:

<input step="0.05" id="TS_dist" class="tableButton" type="number" maxlength="1" size="5" value="0.2" />

http://jsfiddle.net/uh44h3y8/1/

Upvotes: 1

Try adding, step="any" in this input.

Upvotes: 0

Related Questions