NightMICU
NightMICU

Reputation: 9240

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

Upvotes: 8

Views: 14401

Answers (2)

yi2ng2
yi2ng2

Reputation: 139

Can also try:

<input type="number" pattern="[0-9.]*">

Upvotes: 2

Phill Pafford
Phill Pafford

Reputation: 85388

Try adding the step attribute:

Example:

<input type="number" step="0.01" min="0" >

Upvotes: 16

Related Questions