Challenges with creating a contact form using bootstrap modal

I'm facing an issue with a bootstrap modal contact form. It works fine on all browsers except for iPad/Safari. Can anyone help me figure out what's wrong?

  1. On iPad, the modal is positioned to the right and down the page instead of in the center.

  2. When a user selects a form field, the cursor appears outside the modal window.

  3. Text input in a field is not visible until the next field is selected.

The layout breaks only on Safari when viewed on Apple devices, everything else seems to be working well on other browsers like IE and Chrome.

You can view the page here:

There are various elements on the page such as validation, modals, maps, and tabs. I suspect there might be a conflict somewhere due to my limited experience in web programming (2nd year degree student). Any assistance would be greatly appreciated. Thank you. Roy

<!DOCTYPE HTML>
<html>
   ...
    <body>

        <div class="container fill">
            ...

        </div>

        ...

    </body>
</html>

PHP:

<?php
if(isset($_POST['inputEmail'])) {

    $email_to = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="95f7f9f4fdd5f7f9f4fdf7f9f4fdf7f9f4fdbbfbf0e1">[email protected]</a>";
    $email_subject = "Customer Enquiry";

    function died($error) {
       ...
    }

    if(!isset($_POST['inputName']) ||
        !isset($_POST['inputPhone']) ||
        !isset($_POST['inputEmail']) ||        
        !isset($_POST['inputMessage'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }

    $inputName = $_POST['inputName']; 
     ...

// create email headers
$headers = 'From: '.$inputEmail."\r\n".
'Reply-To: '.$inputEmail."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
echo "<meta http-equiv='refresh' content=\"0; url=http://www.abbeystone.net/contact.php\">";
echo "<script>alert('Thankyou your message was sent successfully.'); </script> ";
}
?>

Answer №1

It appears that the positioning of the #myModal element within the HTML markup is causing Safari to display the modal as if it were a child element (which is how it has been positioned).

As stated in the Bootstrap documentation:

Proper Modal Placement

It is recommended to always place a modal's HTML code at a top-level position in your document to prevent other components from affecting its appearance and functionality.

The way the modal renders in Chrome also seems less than ideal, with it appearing under the header and footer elements instead of on top of all page elements (although this is less noticeable due to its centered position).

To resolve the issue, move the modal div and its contents from after the trigger button to before the closing </body> tag:

Current Markup Error

<a href="#myModal" role="button" class="btn btn-info " data-toggle="modal">
  <span class="glyphicon glyphicon-envelope">  </span> Send us a message
</a>
//reposition as below to fix
<div class="modal fade in" id="myModal" aria-hidden="false" style="display: block; padding-left: 0px;">
  //form and stuff...
</div>

Corrected Markup

  <div class="modal fade in" id="myModal" aria-hidden="false" style="display: block; padding-left: 0px;">
    //form and stuff...
  </div>
</body>

Answer №2

Best practices for placing modal markup

For optimal performance and appearance of your modals, make sure to position the HTML code for your modals at the top-level of your document. This will help prevent interference from other components that could impact the functionality or look of your modals.

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

fluid columns gliding from side to side

I'm currently working with Bootstrap to design responsive columns. My goal is to have the next column of content slide in from either the left or right side when the user clicks on the respective arrow button. While I have found solutions for fixed w ...

Is it possible to use JavaScript to append elements with a fade-in effect

I'm looking to add an element with a fade-in animation to another class using JavaScript. Can anyone provide guidance on how to achieve this? Here is what I've tried: success:function(data){ $(".new_posts").append(data); $(".new ...

The "next" button on my carousel is unresponsive and the automatic transitioning feature is not working

I'm having trouble implementing a carousel on my website. The next/previous buttons and automatic slides are not functioning properly. <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <!- ...

Is it feasible to decrease the lateral margins of Bootstrap's container without the need for custom CSS? If so, what is the method?

My web page includes several screenshots to illustrate the issue I am facing. One of my challenges is the scroll bar below the table, which I find displeasing. In an attempt to resolve this, I decided to adjust the lateral margins slightly. Here's a s ...

Using three.js to control the opacity and size of points

I have returned with question number two about points. My query this time revolves around changing the opacity from 0 to 1 and back within specific pixel distances from the emitter. var particleCount = 14, particles = new THREE.Geometry(), pMaterial = new ...

Troubleshooting inconsistent htaccess changes across different pages?

After much trial and error, I have successfully managed to run PHP code within a document that has either an .htm or .html extension. The solution that worked for me was adding the following line of code: AddType application/x-httpd-php .php .html .htm N ...

What significance does the slash hold in a package name when using require for an npm package?

When we "require" non-local NodeJS modules, what does the slash in the module name signify? For instance: from the GitHub page of the ShellJS npm module (link: https://github.com/shelljs/shelljs#javascript) require('shelljs/global'); requir ...

Navigating from a Card to a new View in Angular

I am currently developing a project using Angular (latest version). Within my application, I have the functionality to dynamically generate bootstrap cards from an Order Array and display them in my "Order-Item-Component through its respective template. ...

What could be the reason why my sorting function is not functioning properly?

I am currently in a state of questioning everything I thought I knew. > [ 37, 4, 3, 1, 3, 10, 8, 29, 9, 13, 19, 12, 11, 14, 20, 22, 22, 27, 28, 33, 34 ].sort((a, b) => a > b) [19, 34, 3, 1, 3, 10, 8, 29, 9, 13, 4, 12, 11, 14, 20, 22, 22, 27, 28, ...

The placeholder string is being accepted as the input value for the number

My issue is with a form input of type number. When the form is submitted without entering any number, it treats the placeholder text "rating" as the value. How can I stop this from happening? I need to make sure that the input number field is marked as in ...

How to Update DIV Content in a Child Page Using C#, Javascript, and ASP.NET

I have a master page that sets the basic layout of my website. My goal is to change the contents of a specific div on the child page. I am aware that I can achieve this using the following code snippet: //((HtmlGenericControl)this.Page.Master.Master.FindC ...

How to center a span using Twitter Bootstrap

As a newcomer to Twitter Bootstrap, I'm wondering how I can center a span within a parent row. Currently, I am working with Twitter Bootstrap Version 2.3 instead of 3.1. In version 3.1, there is a center-block feature that I cannot utilize in 2.3. Th ...

How to pass arguments to the `find` method in MongoDB collections

I've been attempting to pass arguments from a function to the MongoDB collection find method. Here's what I have so far: async find() { try { return await db.collection('users').find.apply(null, arguments); } catch(err) { c ...

How can we toggle a function to expand or collapse fields generated in an ngFor loop?

One of my challenges involves managing a div that is repeated using *ngFor in Angular. This results in multiple divs on the page, each containing collapsible fields that can toggle. Essentially, I have nested collapsible fields within other collapsible fie ...

The animation for the Bootstrap modal is not functioning correctly

Whenever I click the button to open the modal window, it just pops up without any animation or fade effect. I attempted to add classes like .fade and .modal-fade to the modal, but nothing changed. You can see it in action on my test page. Simply click th ...

angular 2 checkbox for selecting multiple items at once

Issue I have been searching for solutions to my problem with no luck. I have a table containing multiple rows, each row having a checkbox. I am trying to implement a "select all" and "deselect all" functionality for these checkboxes. Below is an example o ...

Is there a way for me to retrieve the input that the datepicker is being used for?

My approach involves applying the jquery datepicker to input elements with the class txt-date: $('.txt-date').datepicker({ showAnim: "blind", changeMonth: true, changeYear: true, dateFormat: "dd.mm.yy", numberOfMonths: 2 }); ...

NextJS was throwing a warning at me, while Firebase hosting was giving me an error regarding the absence of unique keys for children in lists, even though I

I've been troubleshooting this warning for quite some time, but I can't seem to resolve it. The warning reads as follows: Warning: Each child in a list should have a unique "key" prop. Check the top-level render call using <ul>. ...

Tips on increasing the button size automatically as the elements inside the button grow in size

I have a button with an image and text inside, styled using CSS properties to achieve a specific look. However, I encountered an issue where the text overflows outside of the button when it's too long. I want to find a way to wrap the text inside the ...

Ruby application requires refreshing for Ajax deletions to take effect

I am currently working on developing a task management app using Rails. Each to-do list in the app contains multiple tasks, and my issue lies in deleting a completed task with Ajax without having to manually refresh the page for it to vanish. As I am still ...