# different behaviour web app on pc and mobile browsers

**URL:** <https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655>\
**Category:** General\
**Created:** [May 16, 2017, 8:41am UTC](https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655 "2017-05-16T08:41:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ciro\_Marciano](https://forum.xojo.com/user_avatar/forum.xojo.com/ciro_marciano/32/2208_2.png) [@Ciro\_Marciano](https://forum.xojo.com/u/Ciro_Marciano)\
**Post date:** [May 16, 2017, 8:41am UTC](https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655/1 "2017-05-16T08:41:10Z")

</div>

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?

```auto
// 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()}');")
```

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [May 16, 2017, 9:19am UTC](https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655/2 "2017-05-16T09:19:15Z")

</div>

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](http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000520.html)

---

<div class="post-metadata">

**Author:** ![Ciro\_Marciano](https://forum.xojo.com/user_avatar/forum.xojo.com/ciro_marciano/32/2208_2.png) [@Ciro\_Marciano](https://forum.xojo.com/u/Ciro_Marciano)\
**Post date:** [May 16, 2017, 9:40am UTC](https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655/3 "2017-05-16T09:40:20Z")

</div>

Hi Michel, as you can notice the code above derives from one of your past topic. 🙂  
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?

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [May 16, 2017, 10:43am UTC](https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655/4 "2017-05-16T10:43:04Z")

</div>

[quote=331217:@Ciro Marciano]Hi Michel, as you can notice the code above derives from one of your past topic. 🙂  
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:

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

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:46pm UTC](https://forum.xojo.com/t/different-behaviour-web-app-on-pc-and-mobile-browsers/37655/5 "2020-10-29T18:46:08Z")

</div>


