Is there a way to trap only numbers and the decimal point / minus sign using the newtextfield? I know about setting inputtype = " number" but that only displays numbers but no punctuation so it would be impossible to enter a fractional number or negative number.
Hi John,
Did you try the “decimal” input type keyboard? I can’t remember exactly what that contains, but you can test and see.
http://docs.coronalabs.com/api/type/TextField/inputType.html
Brent
I tried number… and phone… neither have the decimal point. I did try decimal (thank you), but it just displays a regular keyboard. Is it supposed to show a numeric keyboard? My client really wants a numeric keyboard with decimal point - and of course shows me an app on the iphone that does that.
Hi John,
There are some additional keyboard types for iOS which we added in a more recent daily build (so you’d have to use that to access them). These correspond to the iOS types and are documented here:
http://docs.coronalabs.com/daily/api/type/TextField/inputType.html
I’m not sure which type yields the keyboard that your client showed you. Perhaps “UIKeyboardTypeNumbersAndPunctuation”.
Brent
Thanks… it looks like it displays fine on iOS, but not on Android. I’m assuming Android does not have those keyboard types. Or is there something else I’m missing?
Hi John,
Those additional keyboard types are iOS-only. On Android, I suppose you may need to detect the environment (Android), use a keyboard that contains all of the options you need, and then manually control/filter which are allowed to be input into the field.
Brent
Hi John,
Did you try the “decimal” input type keyboard? I can’t remember exactly what that contains, but you can test and see.
http://docs.coronalabs.com/api/type/TextField/inputType.html
Brent
I tried number… and phone… neither have the decimal point. I did try decimal (thank you), but it just displays a regular keyboard. Is it supposed to show a numeric keyboard? My client really wants a numeric keyboard with decimal point - and of course shows me an app on the iphone that does that.
Hi John,
There are some additional keyboard types for iOS which we added in a more recent daily build (so you’d have to use that to access them). These correspond to the iOS types and are documented here:
http://docs.coronalabs.com/daily/api/type/TextField/inputType.html
I’m not sure which type yields the keyboard that your client showed you. Perhaps “UIKeyboardTypeNumbersAndPunctuation”.
Brent
Thanks… it looks like it displays fine on iOS, but not on Android. I’m assuming Android does not have those keyboard types. Or is there something else I’m missing?
Hi John,
Those additional keyboard types are iOS-only. On Android, I suppose you may need to detect the environment (Android), use a keyboard that contains all of the options you need, and then manually control/filter which are allowed to be input into the field.
Brent