I am facing an issue with the text input focus on my Cordova Android app, as it is not behaving as expected. Strangely, the focus works perfectly

My Cordova application has an interesting behavior discrepancy when using the Cordova serve option. I have a text input field where users can enter a link, and if they forget to include 'http://' or 'https://' at the beginning of the URL, it automatically adds it once the string length reaches more than 8 characters.

When I use 'cordova serve android' to run the app directly in the browser, the functionality works as expected. For example, typing in 'www.nba.' automatically changes to 'http://www.nba.'.

However, when I run 'cordova run android' and use the app on a mobile device, the same code behaves differently. For instance, when I input 'www.nba.', the string changes to 'http://w|ww.nba.' with the cursor positioned between the first and second 'w' in 'www'.

I have tested this with various keyboards, including the stock ROM keyboard, but the issue persists consistently. Here is the simple code snippet responsible for this functionality:

var pattern = new RegExp("^(http|https)://");
if (pattern.test($scope.post.link) === false) {
     $scope.post.link = 'http://' + $scope.post.link;
}

Can anyone provide insight into why this behavior occurs on the Cordova build on the phone but not during actual Cordova serve?

Answer №1

It might not seem logical, but attempt to avoid using forward slashes by using this code:

new RegExp("^(http|https):\/\/");

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips on pairing elements from a ngFor processed list with another list using ngIf

If we have a list such as the one shown below: elements = [ { id: 1, name: "one" }, { id: 3, name: "three" }, { id: 5, name: "five" }, { id: 6, name: "six" }, ]; lists = [ { id: 5, name: "five" }, { id: 9, ...

Having trouble creating a new function in Protractor to retrieve FindElement?

I am looking to enhance the functionalities of FindElement and FindArrayElement libraries. Is it possible to create something like this: //ef_extend.js protractor.ElementFinder.prototype.getColumnList = function() { return this.all(webdriver.By.xpath(&a ...

Insert an ArrayList of Strings into an ArrayList of Custom Objects

I retrieve data from shared preferences: SharedPreferences sharedPref = ImageListViewActivity.this.getSharedPreferences("settings",Context.MODE_PRIVATE; String MyString1 = sharedPref.getString("MyPackage.NameOfSharedPref",null); String MyString2 = sharedP ...

Issue: Using the useParams() hook triggers a TypeError, stating that useContext(...) is undefined

Having trouble with the useParams() react hook to fetch a parameter, and encountering this error: Error: useContext(...) is undefined The hooks file throws this error on line 40: /modules/hooks.js:40 39 | > 40 | const match = useContext(Context) ...

Align two DIVs in the correct layout: One as a sidebar that remains fixed, and the other as an expanding element

I am currently working on a code snippet to build a basic website featuring two main sections: a sidebar and the main content: html, body { height: 100%; margin: 0; } .container { display: flex; flex-direction: row; height: 100%; } .sidebar { ...

How to Send and Receive Data in One Request Using Android Studio and Web API

Currently, I am working on an Android App using Android Studio and the backend is being developed using Asp.Net Web API. Web Api Part [System.Web.Http.AcceptVerbs("GET", "POST")] [System.Web.Http.HttpGet] public dynamic GetTest(string name) { List< ...

Arranging various JavaScript arrays

I've been working on a script using the Haversine formula, but I'm running into an issue where it always directs me to the first location in the array, no matter how many times I switch them around. Any suggestions? var locations = new Array( ...

Implementing the row delete function in MUI DataGrid using JavaScript

My grid has a delete icon button in each row, but it's not deleting the row. Can someone please help me with this issue? I'm working on a todo app where each row should have its own delete button. I'm struggling to connect the deleteTodo co ...

Generating unique names based on input from users

We are working with an array containing names and an input field where users can enter a string to receive name suggestions. The array includes names like Alex and Anna, and when the user types "a," we want to suggest these names. Below is the code snippet ...

Having trouble getting the items to show up on the canvas

I have been struggling to implement JavaScript on a canvas in order to display mice in the holes using the mouse coordinates. Despite trying many different methods and spending close to a month on this project, I still can't seem to get it to work acr ...

Calculate the difference and sum of time values with varying signs in JavaScript

-12:00 - 5:30 => -6:30 -2:00 - 5:30 => 3:30 00:00 - 5:30 => -5:30 6:00 - 2:30 => 3:30 I am interested in subtracting time with both positive and negative indices. let myCountries = [ { countryName: "NewZealand", ...

Using the Count() function in PHP to update information upon page refresh

I have created a basic cart that displays a div containing purchased items when hovered over. The issue I am facing is that every time I click on the add to cart button, it doesn't immediately update the number of items in the cart. I have to manually ...

If you are using Windows 10 and encountering issues with npm and Babel, please attempt to rerun the

error identifier npm install --save-dev css-loader style-loader We recommend executing this command as an administrator to resolve the issue. ...

Instructions for overlaying a text onto the select input field in DataTables

I am currently utilizing the DataTables select input feature to capture only the first three columns of data. However, I would like to enhance this by adding a text element above the select inputs within the DataTables interface. Is there a way to achieve ...

The input type "number" does not seem to be compatible with the currency pipe feature

The currency pipe seems to not be working when using the input type number. The web page is not displaying any value. I have searched various blogs and it appears that the currency pipe only works with input type text, but my requirement necessitates the ...

Display the Image Element in Angular only when the image actually exists

In my HTML code, I have two sibling elements - one is an image and the other is a div. I want to display the image element if the image exists, and show the div element if the image doesn't exist. Here's how my elements are structured: <img ...

The Hydration error is caused by dynamic imports in NextJS v14.2.3

While updating NextJS from v13 to v14, I encountered a Hydration error due to dynamic imports. Is there a way to resolve this issue? const MyComponent = dynamic(() => import('../components/MyComponent')) Is there a fix that allows for both la ...

Utilizing jQuery and AJAX, execute a PHP query based on the user's input and showcase the query's outcome without reloading the page

For the past 24 hours, I've been on a quest to find a solution. Although I've come across similar inquiries, either the responses are too complex for my specific scenario (resulting in confusion) or they are of poor quality. The crux of my issue ...

transforming a string path into an input stream

Currently in the process of developing a chatting app utilizing the Quickblox chat API. User registration, authentication, basic peer-to-peer chat, and group chat functionalities have all been successfully implemented. I am now working on incorporating vid ...

What is the most effective way to alphabetically organize a Javascript array?

Is there a more professional way to sort people alphabetically by last name in an array? Here is the array I'm working with: const people = [ 'Bernhard, Sandra', 'Bethea, Erin', 'Becker, Carl', 'Bentsen, Lloyd' ...