Having trouble formatting the Modal form in Bootstrap when using AngularJS

The code runs successfully, but I am struggling to get the desired output. You can find the code here.

<div class="modal fade" id="signup" tabindex="-1" role="dialog">
<div class="modal-dialog modal-sm">
    <div class="modal-content">
        <form name="registration" ngnovalidate="" class="ng-pristine ng-invalid ng-invalid-required ng-valid-pattern ng-valid-email ng-valid-minlength">
        <div class="modal-header ng-scope">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="modal-title">Registration</h4>
        </div>
        <div class="modal-body ng-scope" id="modalbody">

            <div class="col-sm-offset-1 col-sm-10">
                <input type="text" name="username" id="username" placeholder="Username" ng-model="user.username" ng-required="true" ng-pattern="/^[a-zA-Z0-9]*$/" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-pattern" required="required"><br>
                <p ng-show="registration.username.$touched &amp;&amp; registration.username.$error.required" class="ng-hide">Please enter a Username!</p>
                <p ng-show="registration.username.$error.pattern" class="ng-hide">Please enter a Valid Username (No special characters)!</p>


                <input type="email" name="email" id="email" placeholder="Email" ng-model="user.email" ng-required="true" ng-pattern="/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/" class="ng-pristine ng-untouched ng-empty ng-valid-email ng-invalid ng-invalid-required ng-valid-pattern" required="required"><br>
                <p ng-show="registration.email.$invalid &amp;&amp; registration.email.$touched" class="ng-hide">Please enter a valid email!</p>


                <input type="password" name="password1" id="password1" placeholder="Password" ng-model="user.password1" ng-required="true" ng-minlength="6" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-minlength" required="required"><br>
                <p ng-show="registration.password1.$invalid &amp;&amp; registration.password1.$touched" class="ng-hide">Passwords must be at least 6 characters!</p>

                <input type="password" name="password2" id="password2" placeholder="Confirm Password" ng-model="user.password2" ng-required="true" ng-minlength="6" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-minlength" required="required"><br>
                <p ng-show="registration.password2.$invalid &amp;&amp; registration.password2.$touched" class="ng-hide">Passwords must be at least 6 characters!</p>
            </div>




        </form>
        </div>
            <div class="modal-footer">
                <input type="submit" class="btn btn-primary" ng-click="submit(user)">
            </div>
    </div>
</div>

I am attempting to center the form and ensure it is correctly positioned in the header, body, and footer sections. However, whenever I make changes to the code or CSS, the form seems to move out of place from the body section and the footer gets misaligned. I am unsure if this issue is due to using Bootstrap and AngularJS.

https://i.sstatic.net/EsxN4.png

Answer №1

<div class="modal fade" id="signup" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">

            <div class="modal-header ng-scope">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="modal-title">Sign Up</h4>
            </div>
            <div class="modal-body ng-scope" id="modalbody">
                <form name="registration" ngnovalidate="" class="ng-pristine ng-invalid ng-invalid-required ng-valid-pattern ng-valid-email ng-valid-minlength">
                    <div class="col-sm-offset-1 col-sm-10">
                        <input type="text" name="username" id="username" placeholder="Username" ng-model="user.username" ng-required="true" ng-pattern="/^[a-zA-Z0-9]*$/" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-pattern" required="required"><br>
                        <p ng-show="registration.username.$touched &amp;&amp; registration.username.$error.required" class="ng-hide">Please enter a Username!</p>
                        <p ng-show="registration.username.$error.pattern" class="ng-hide">Please enter a Valid Username (No special characters)!</p>


                        <input type="email" name="email" id="email" placeholder="Email" ng-model="user.email" ng-required="true" ng-pattern="/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/" class="ng-pristine ng-untouched ng-empty ng-valid-email ng-invalid ng-invalid-required ng-valid-pattern" required="required"><br>
                        <p ng-show="registration.email.$invalid &amp;&amp; registration.email.$touched" class="ng-hide">Please enter a valid email!</p>


                        <input type="password" name="password1" id="password1" placeholder="Password" ng-model="user.password1" ng-required="true" ng-minlength="6" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-minlength" required="required"><br>
                        <p ng-show="registration.password1.$invalid &amp;&amp; registration.password1.$touched" class="ng-hide">Passwords must be at least 6 characters!</p>

                        <input type="password" name="password2" id="password2" placeholder="Confirm Password" ng-model="user.password2" ng-required="true" ng-minlength="6" class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-minlength" required="required"><br>
                        <p ng-show="registration.password2.$invalid &amp;&amp; registration.password2.$touched" class="ng-hide">Passwords must be at least 6 characters!</p>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <input type="submit" class="btn btn-primary" ng-click="submit(user)">
            </div>
        </div>
    </div>
</div>

Ensure to validate the opening and closing tags within the form.

Answer №2

After reviewing your code, I made some adjustments. It appears that the placement of your <div> tags may be incorrect. Please try implementing the following changes:

<div class="modal fade" id="signup" tabindex="-1" role="dialog">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">

            <div class="modal-header ng-scope">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="modal-title">Registration</h4>
            </div>
            <div class="modal-body ng-scope" id="modalbody">
                <div class="row">
                    <form name="registration" ngnovalidate=""
                          class="ng-pristine ng-invalid ng-invalid-required ng-valid-pattern ng-valid-email ng-valid-minlength">
                        <div class="col-sm-offset-1 col-sm-10">
                            <input type="text" name="username" id="username" placeholder="Username"
                                   ng-model="user.username"
                                   ng-required="true" ng-pattern="/^[a-zA-Z0-9]*$/"
                                   class="ng-pristine ng-untouched ng-empty ng-invalid ng-invalid-required ng-valid-pattern"
                                   required="required"><br>

                            <p ng-show="registration.username.$touched &amp;&amp; registration.username.$error.required"
                               class="ng-hide">Please enter a Username!</p>

                            <p ng-show="registration.username.$error.pattern" class="ng-hide">Please enter a Valid
                                Username
                                (No special characters)!</p>


                            <input type="email" name="email" id="email" placeholder="Email" ng-model="user.email"
                                   ng-required="true" ng-pattern="/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/"
                                   class="ng-pristine ng-untouched ng-empty ng-valid-email ng-invalid ng-invalid-required ng-valid-pattern"
                                   required="required"><br>

                            <p ng-show="registration.email.$invalid &amp;&amp; registration.email.$touched"
                               class="ng-hide">
                                Please enter a valid email!</p>


…(remaining content remains the same)…

I hope these modifications assist you in resolving the issue.

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

JavaScript - Unable to retrieve individual elements from an array generated by parsing a CSV file

I have a csv file generated by a database that I need to convert into an array. The file is in the same folder as my script. Here is how the csv file is formatted: (I am unable to show the original data) https://i.sstatic.net/SgKt1.png https://i.sstatic ...

Comparing boolean values in React JS

I am working with a React JavaScript code in which I am iterating through a series of boolean values. The issue I am facing is that when 'data.nextrow' is false, I expect nextrow1 to also be false but it ends up being set to true instead. co ...

Explore GLB/GLTF files without using loader.load

Looking for some guidance on utilizing the dat.gui package in my exploration of three.js. Struggling to figure out how to access the model outside of the loader.load function. let model loader.load('new.glb', function(gltf){ model = gltf sce ...

Retrieve a particular item from an array of JSON objects

My services.js file is structured like this: var app = angular.module('starter.services', []) .factory('Studies',function($http,$filter){ var studies = []; $http.get("studies.json").success( f ...

Creating an invoice or money receipt using HTML is a straightforward process that involves using specific code and

Currently, I'm in the process of developing an application for a land developer company. The administrator of this application will be responsible for creating invoices, money receipts, and bills. I am looking to design these documents to resemble th ...

React JS Issue: Real-time Clock not updating in React component

I have a react application designed for attendance tracking. The issue at hand is that the time displayed does not update in real-time. Once the app is initially rendered, the time remains static. (It only updates when the app is reloaded) The code snipp ...

Showing and hiding multiple elements in Jquery while ensuring that other elements are hidden if one is shown

Greetings, I have searched high and low but cannot seem to find a solution to my specific issue. My problem is that I have multiple columns with "read more" buttons that, when clicked, reveal hidden content. The button then changes to "close" to hide the ...

Maintaining the current tabIndex while navigating between NextJS pages involves setting the tabIndex state in each

What is the best way to store and retrieve the current tabIndex when moving from one page to another? (One idea is to create a function that saves the current index in the sessionStorage and then retrieves it when the page loads) For example: https://i. ...

Enhancing Angular 5 with CustomEvent Polyfill for JavaScript

After implementing the code snippet in main.ts file, I encountered an issue with CustomEvent not being added to the window object correctly. Strangely, when I manually add CustomEvent using the JavaScript console, it works fine. This problem arises specifi ...

Increase the identifier of my input text when a table row is duplicated through Javascript

I have a table with only one row that contains various elements like textboxes and buttons. I want to clone the table row using the append() function when a button is clicked. However, I am facing an issue - how can I increment the id of the textboxes and ...

Creating a loading screen in Angular2: Step-by-step guide

How can you best integrate a preloader in Angular 2? ...

What are the steps to implement localStorage in Vuejs3?

I'm feeling a bit lost when it comes to localStorage and its usage. I have a component called Statistic.vue which displays a modal at the end. Statistic.vue <template> <p class='modal'>{{numberOfGames}}</p> </template& ...

Retrieving the function or state of a component within a higher-order component (HOC) wrapper

Hey there! I have a situation where Component A, which extends React.component, is wrapped with a higher order Component B. Now, in the methods of Component B, I need to either setState for Component A or call a function in A to do the setState. How can I ...

Exploring request parameters within an Express router

I'm currently facing an issue with accessing request parameters in my express router. In my server.js file, I have the following setup: app.use('/user/:id/profile', require('./routes/profile')); Within my ./routes/profile.js fil ...

Having trouble establishing a connection between the client and server while using Node.js with socket.io, Express, and an HTML file

While following a tutorial on YouTube for creating a simple web game with lobbies/rooms, I encountered an issue. When attempting to establish a connection between the client and server, the expected "a user connected" text did not show up in the console as ...

send a message to all clients using socket.io

I am having trouble figuring out how to broadcast a message from the client or another NodeJS file to all clients. While I was able to send messages to the server successfully, I am not able to reach every other client. Server code: var io = require(&ap ...

Attempting to mimic $http functionality within Angular

I've been working on setting up some basic test coverage for a service I created. Here's the code for my service: App.factory('encounterService', function ($resource, $rootScope) { return { encounters: [], encountersTotalCoun ...

Ways to achieve perfect alignment for SVG text within its container, as opposed to stretching across the entire webpage

Recently, I've been working on a customizable photo frame designer using SVG. One of the key features allows users to add their own text to the frame. To achieve this, I'm utilizing jQuery's .keyup function. However, the issue I'm facin ...

Styling divs to be proportionally larger or smaller within a layout

Is there a way to design a layout that automatically scales without relying on the height property? Currently, I'm using a float layout between two divs, as depicted in the image below. The issue arises when the content within these boxes varies in si ...

Reorganizing JSON data with ES6 techniques

I have a scenario where I need to update tire quantities in an array like this: tires: [{ name: "fancyProduct1", quantity: 1 }, { name: "fancyProduct1", quantity: 1 }, { name: "fancyProduct1", quantity: 1 }, { name: "fancyProduct2", quanti ...