Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best way to enter numeric values with decimal points?

In my app users need to be able to enter numeric values with decimal places. The iPhone doesn't provides a keyboard that's specific for this purpose - only a number pad and a keyboard with numbers and symbols.

Is there an easy way to use the latter and prevent any non-numeric input from being entered without having to regex the final result?

Thanks!

like image 303
Andrew Grant Avatar asked Nov 09 '08 19:11

Andrew Grant


People also ask

What is the best data type for a number with a decimal place?

Numbers that contain a decimal point are stored in a data type called REAL. Variables that use the real data type can accept both positive and negative numbers with a decimal place.

How do you enter numeric value?

Use scientific notation, not e (which Mastering evaluates as the constant 2.718...) or E. For example, enter 1.23*10^5 instead of 1.23e+5 or 1.23E+5. Use commas only as separators between multiple expressions within a single answer box, such as "1999,2009".


1 Answers

I think it would be good to point out that as of iOS 4.1 you can use the new UIKeyboardTypeDecimalPad.

So now you just have to:

myTextField.keyboardType=UIKeyboardTypeDecimalPad; 
like image 64
Zebs Avatar answered Oct 09 '22 01:10

Zebs