Hello, in the code below I have an HTML input which should accept only numbers. The functionality works in Chrome and Edge browsers, but when the page is loaded in the Webviewer component, any keys get accepted. Seems the onlyNumberKey function is not triggered. Any workarounds ?
Great. I've got it setup and the companion no longer crashes.
However, I now have an access issue to read the .html file.
The original WebViewer had no problem displaying the local file which was uploaded via media:
file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/assets/salogin.html
The CustomWebview is giving me an error:
net:ERR_ACCESS_DENIED
I've tried changing the file settings to no avail. http://localhost/salogin.html
file:///appinventor_asset/salogin.html
@ChrisWard, in the finished product, the HTML page will be hosted at a cloud provider, and will also be accessed from desktop browsers. I'm trying to keep the interoperability at a maximum to avoid switching between features in the app and webpage.
You should have told us that from the beginning TechFarmer! That is very different from interaction with an HTML page in App Assets.
Edit - there is a good chance that the Custom Web View will work with an online page, but you need to correct your code, it's not HTML5 compliant. Also, life would be easier if you didn't try to restrict the length of the input - if necessary you can reject input that exceeds the limit. That way, the numbers problem is solved as the input can be set to numbers only. You can always have a label alongside saying "max 7 digits".
I have uploaded the HTML to my website, so the App Project should work for you via the Companion. The App Project contains the Custom Web Viewer Extension, which I know you have already downloaded. Once you have the Project, let me know and I will delete it from this post as Users must obtain Extensions from the appropriate channel.
Indeed, for a regular number it works as expected. When I initially posted regarding the Javascript event, I hoped that once the key trap worked, I could expand the same principle to a custom mask on an input box and trap user input in realtime.
Unfortunately, the requirement for having the keypress event is still needed (customer), rather than performing the validation at submit. What would be the appropriate channel for requesting a bug fix ?