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

Adobe AIR Development

Reply
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900
Accepted Solution

No more than one period (.) in an input

[ Edited ]

Hey guys,

 

I've created a textInput that takes 0-9 numbers plus a decimal point from a custom keypad.

 

Now since this will be a number, I want the input text to handle the fact that ONLY one decimal is entered. What I want is that if a second decimal is entered, a warning dialog should appear, and reset the input text to 0.

 

EDIT: Code not needed.

Reply below.

 

Any help would be great.. thanks!

 

G

 

 

 

Developer
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: No more than one period (.) in an input

hey gpatton,

 

the solution to this problem is available in another thread compliments of TheDarkin1978. He did a check for the amount of decimals in the textinput and then simply canceled the event  if it was too many decimals and it would just never show up in the textinput.

 

here is the link to the thread:

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/textField-restrict-how-to-just-al...

 

I also recommend instead of having an alertdialog show up to just not allow the decimal to be inputted into the TextInput. hope that helps. good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Developer
Posts: 193
Registered: ‎12-29-2010
My Device: Bold 9900

Re: No more than one period (.) in an input

In addition to the solution provided in the link above, I did the following if anybody want's to implement it.

 

I have a custom number pad on my screen and also wanted to restrict the input to 1 decimal as well.

 

So with my input text field titled "textInput"...I did the following in my event listener:

 

 

private function numPadDecimalClicked(e:MouseEvent):void {
			
			if(textInput.textField.text.indexOf(".") != -1) {
				e.preventDefault();
			} else {
				textInput.textField.appendText(".");
			}			
		}

 

Hope that helps someone else.

 

G