Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
New Contributor
Posts: 9
Registered: ‎10-10-2012
My Device: Playbook
My Carrier: AT&T
Accepted Solution

HTML Number input is not accepting decimal places

I am using html5 number input type. But its not accepting decimal places. Any suggestion welcome. Thanks

Developer
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook
My Carrier: Loop

Re: HTML Number input is not accepting decimal places

Have you tried using the step attribute? It is used to specify to the precision of the decimals you want. eg. to take values like 11.24; you should do something like:

<input type="number" step="0.01" min="0" >
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
New Contributor
Posts: 9
Registered: ‎10-10-2012
My Device: Playbook
My Carrier: AT&T

Re: HTML Number input is not accepting decimal places

 

step attribute is not working, possibly BB10 bug. Some post says it is fixed in 10.1 or future releases

New Developer
Posts: 7
Registered: ‎01-13-2013
My Device: Curve 9350
My Carrier: Vodafone

Re: HTML Number input is not accepting decimal places

Without a 'step' attribute, as you might expect, when you try to enter a decimal (floating point) number and submit the form, it results in a form validation error.


'step' attribute controls the increase/decrease when clicking the up/down buttons on the field and also determines which values are valid. A step of 0.3 will allow values such as 0.3, 0.6, 0.9 etc, but not 1 or 2.

As you have decimal valued input allowed,  user can very well enter something like '3.425', '3.0' or '3'. A 'step' attribute of say '0.01' will not accept an input of '3.456'. So for this scenario, you can try something like:

<input type="number" step="any"/>

Hope it helps.

Developer
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook
My Carrier: Loop

Re: HTML Number input is not accepting decimal places

So which OS version are you testing in

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 185
Registered: ‎08-17-2008
My Device: Red BlackBerry Z10
My Carrier: Vodafone

Re: HTML Number input is not accepting decimal places

[ Edited ]

is it really solved in 10.1?


If for example I type 51.2, when i go to other field change to 512 automatically

 

Thanks in advance.

Josep Maria
New Developer
Posts: 11
Registered: ‎03-20-2013
My Device: Playbook
My Carrier: Nope

Re: HTML Number input is not accepting decimal places

f nothing helps you can still use two input field.

New Contributor
Posts: 9
Registered: ‎10-10-2012
My Device: Playbook
My Carrier: AT&T

Re: HTML Number input is not accepting decimal places

 

The below HTML syntax works with latest BB10 update.

 

<input id="txtAmount" value="" type="Number" step="0.01" min="0"/>

Developer
Posts: 185
Registered: ‎08-17-2008
My Device: Red BlackBerry Z10
My Carrier: Vodafone

Re: HTML Number input is not accepting decimal places

Thanks for your replies.

 

I was testing with OS 10.1 an don't works. Now I tested with OS 10.2 and works fine.

 

All the best.

Josep Maria