different behaviour web app on pc and mobile browsers

Hi!

I’m having some serious problems on my web app if I open it on a mobile browser…

for example, in the shown event of some textbox I have this code to avoid insert characters other than 0 1 2 3 4 5 6 7 8 9 - , . (I need only numeric input, is a discount field)

but on pc I can insert the minus “-”, on mobile (android/ios) I cannot insert!

sometimes on android, I cannot insert more than one character…is very strange, any suggestion?

// BLOCCO TASTI NON NUMERICI
		self.ExecuteJavaScript("document.getElementById('"+me.controlId+"').setAttribute('onkeydown','" +_
		"if (event.keyCode >57 && event.keyCode < 93 || event.keyCode >105 && event.keyCode!= 109 && event.keyCode!= 188  )" +_
		" {event.preventDefault()}');")

I believe what happens is that you take into account the numeric keypad minus, but not the typewriter one (code 45). Same thing for comma, which is 44 in the typewriter keyboard. Mobile devices and virtual keyboards do not generate numeric keypad codes.

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000520.html

Hi Michel, as you can notice the code above derives from one of your past topic. :slight_smile:
but on an normal pc works both with minus on the keyboard and on the numeric keypad

So, do you suggest to add
&& event.keyCode= !44 && event.keyCode= !45
to the above code?

[quote=331217:@Ciro Marciano]Hi Michel, as you can notice the code above derives from one of your past topic. :slight_smile:
but on an normal pc works both with minus on the keyboard and on the numeric keypad

So, do you suggest to add
&& event.keyCode= !44 && event.keyCode= !45
to the above code?[/quote]

Yep. That will work, if you place the exclamation point right:

&& event.keyCode != 44 && event.keyCode != 45