Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decimals in jQuery Mobile number input

Working on a jQuery Mobile form with an input for entering dollar amounts. <input type="number" name="amount"/> pops up the numeric entry on devices and restricts to number only. But when I enter a decimal amount and attempt to submit the form, it focuses on the amount field and says "Invalid Value."

How do I keep the theme and data type while allowing digits?

Many thanks

like image 964
NightMICU Avatar asked Nov 11 '11 20:11

NightMICU


2 Answers

Try adding the step attribute:

  • http://www.w3.org/TR/html-markup/input.number.html#input.number.attrs.step.float

Example:

<input type="number" step="0.01" min="0" >
like image 132
Phill Pafford Avatar answered Sep 19 '22 13:09

Phill Pafford


Can also try:

<input type="number" pattern="[0-9.]*">
like image 38
yi2ng2 Avatar answered Sep 20 '22 13:09

yi2ng2