MAC Safari is not registering input fields

I'm experiencing a small issue with a form that has two input fields for indicating time (in the format HH:mm) that are very close together, like this:

https://i.sstatic.net/u2GzN.jpg

Here is the HTML code snippet:

<label>
    <span>Hour*</span>
    <input type="text" class="input-sm" ng-model="ev.date_mn" name="ev_date_mn" placeholder="00" maxlength="2" required/>
    <span class="divider">:</span>
    <input type="text" class="input-sm" ng-model="ev.date_hr" name="ev_date_hr" placeholder="00" maxlength="2" required/>
</label>

And here is the corresponding CSS code:

.wrapper.crea-evento div.input-group div.input-section label > span {
    width: 40%;
}

.wrapper.crea-evento div.input-group div.input-section label > span.divider {
    width: auto;
    margin: 0 5px;
    float: right;
}

.wrapper.crea-evento div.input-group div.input-section input {
    width: 50%;
    float: right;
}

.wrapper.crea-evento div.input-group div.input-section input.input-sm {
    width: 65px;
}

The issue arises only in Safari. When I click on the first input field (hours), it automatically focuses on the second one (minutes). The only way to enter data in the hours input field is by using the TAB key on the keyboard, which is not ideal.

In Chrome, Firefox, and IE (9+ and Edge as well), everything works fine. Only Safari exhibits this behavior. Could it potentially be a bug related to webkit? I've come across information about Safari's "autofocus" feature, but typically associated with mobile devices, not desktop browsers.

Answer №1

Your HTML code is incorrect; the label element should only have one form element inside it. Because of this error, different browsers are trying to focus on a specific input element - Chrome, Firefox, and Internet Explorer/Edge all end up focusing on the first one. However, Safari may be focusing on the last input or cycling through each one in sequence.

To fix this issue, you need to adjust your HTML so that each label is linked to only one input.

Answer №2

Interestingly, Safari seems to be misinterpreting the HTML5 standard in this case: https://www.w3.org/TR/html5/forms.html#the-label-element

If the for attribute is not specified, but the label element has a labelable element descendant, then the first such descendant in tree order is the label element’s labeled control.

If a label element has interactive content other than its labeled control, the activation behavior of the label element for events targeted at those interactive content descendants and any descendants of those must be to do nothing.

This issue should align with the behavior of other browsers. It appears to be a persistent bug in Safari, even in iOS 11.3.

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

Unable to display background image on Webpage due to blank page issue while uploading it with HTML and CSS

I've been attempting to build a webpage with an image as the background, but I seem to be facing some issues. Instead of seeing the desired image, all I get is a blank white page. The folder named "images" is located in the same directory as my HTML a ...

accordions that are supposed to adapt to different screen sizes are

My custom responsive accordions are not functioning as expected. The requirement is to display headings and content for desktop view, but switch to accordions on smaller devices. I have managed to do this, however, when resizing the window, the functionali ...

Tips for Displaying and Concealing Tables Using Radio Buttons

Does anyone know how to refactor the jQuery code to toggle between two selection options (Yes and No)? This is the jQuery code I have tried: $(document).ready(function() { $("#send_to_one").hide(); $("input:radio[name='decision']").chan ...

Tips for incorporating transition animations into route changes in next.js

On the homepage, there are 2 links that I want to have distinct transition animations for. For example, if I click the link on the left, the animation should start from the left and move towards the right when changing routes. ...

Adding various image files to the canvas

I am facing an issue with my code where I need to find images inserted by the user into a div and then combine them into one image in a canvas when the "snap" button is clicked. While I can successfully locate, position, and resize the images inside the ca ...

"Enhance Your Dining Experience with a Menu that Captiv

My goal is to create a small menu with only the initial letter of each name visible, but when focused, I want the full word to appear. Here's an example: css: .menu:focus { } php: <nav> <li class="menu"><a ...

The div elements are constantly shifting positions when viewed in Internet Explorer

After completing my website and testing it across different browsers, I noticed an issue with IE. The contact div and navigation shift around the page in this browser specifically. Can anyone help me out with some code to fix this problem? Link to live ex ...

Determine the difference between a CSS selector string and an XPath string

Developing a compact querying module (using js) for html is my current project, and I aim to create a versatile query(selector) function that can handle both css selectors and XPath selectors in string form. My dilemma lies in determining whether a given ...

What is the best way to ensure that my mobile website with fixed-width always appears fully zoomed in?

How can I ensure that my fixed width website always appears fully zoomed in on Webkit browsers such as iPhone and Android? Currently, the site looks good on an iPhone but appears too small or zoomed out on higher resolution Android phones. I have tried u ...

Issues with AngularJS UI Router functionality are being experienced specifically on localhost

What is causing the discrepancy in UI-Router functionality between JSFiddle and localhost? The localhost link is http://127.0.0.1:54046/preview/app/index.html. Have I overlooked something crucial here? There are no visible JS errors present in the console. ...

Resolving the Material-UI NextJS Button Styling Dilemma

I've encountered an issue with the styling of a few buttons in JS. When I apply a styling class using className, the formatting works fine on the initial render but loses its styling on subsequent refreshes. This problem is specific to two individual ...

Using Javascript's OnChange event to dynamically update data

Attempting to achieve a seemingly straightforward task, but encountering obstacles. The goal is to trigger a JavaScript onChange command and instantly update a radar chart when a numerical value in a form is altered. While the initial values are successful ...

Guide on aligning text beneath and to the side of an image, and positioning them in the same row using CSS Bootstrap 4

I am looking to organize two different texts alongside and under an image within a single article. I also want these two articles to be displayed in the same row when the window size is col-md or larger. https://i.sstatic.net/ZjigH.jpg The second article ...

Efficiently Displaying Multiple HTML Elements in React Native WebView

I am currently working on developing an Epub reader in React Native and facing a challenge. I need to find a way to efficiently transfer multiple html content files from the Epub container to the webview in order to achieve seamless pagination. ...

Does activating a hyperlink on an anchor element count as a cross-origin request?

Understanding CORS: Cross-origin resource sharing (CORS) is a method that enables limited resources on a webpage to be requested from a different domain than the one where the initial resource originated. Let's say I have a simple HTML page with a li ...

I need to position the CSS vertical scrollbar on the right side of the page

I can't figure out how to move the vertical scrollbar to sit on the right side of my site's work page. Any help would be greatly appreciated. Below is the provided HTML code: <div class="heading"> <h1>PRINT</h1> &l ...

What is the best way for me to automatically square a number by simply clicking a button?

How do I create a functionality that multiplies a number by itself when a specific button is clicked? I want this operation to only occur when the equals button is pressed. I have been attempting to set this up for over an hour without success. My current ...

how to position one div above another using css

I currently have a page layout with 7 different div elements structured like this; <div id="container"> <div id="head"></div> <div id="A"> <div id="A1">A1</div> <div id="A2"></div> ...

How can one element be made to rely on the presence of another element?

I'm currently working on my portfolio website and encountering an issue. Whenever I hover over an image of a project, the image expands in size, becomes less transparent, and a description of the project pops up. However, I would like to include a lin ...

Utilize PHP to create HTML permalinks for optimal linking functionality

I am experiencing an issue with HTML and PHP combination. Here is the code snippet causing trouble: $args = array( 'post_type' => 'program', 'posts_per_page' => 100 ); $loop = new WP_Query( $args ); while ( ...