Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeP04 committed Jun 7, 2021
1 parent 768a1cb commit ed858f0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
File renamed without changes.
File renamed without changes
File renamed without changes
8 changes: 4 additions & 4 deletions starterOnly/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<title>Reservation</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="modal.css" />
<link rel="stylesheet" href="./css/modal.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link
href="https://fonts.googleapis.com/css?family=DM+Sans"
Expand All @@ -14,7 +14,7 @@
<body>
<div class="topnav" id="myTopnav">
<div class="header-logo">
<img alt="logo" src="Logo.png" width="auto" height="auto" />
<img alt="logo" src="./images/Logo.png" width="auto" height="auto" />
</div>
<div class="main-navbar">

Expand Down Expand Up @@ -45,7 +45,7 @@ <h1 class="hero-headline">
</button>
</div>
<div class="hero-img">
<img src="./bg_img.jpg" alt="img" />
<img src="./images/bg_img.jpg" alt="img" />
</div>
<button class="btn-signup modal-btn">
je m'inscris
Expand Down Expand Up @@ -217,6 +217,6 @@ <h1 class="hero-headline">
Copyright 2014 - 2020, GameOn Inc.
</p>
</footer>
<script src="modal.js"></script>
<script src="./javascript/modal.js"></script>
</body>
</html>
36 changes: 30 additions & 6 deletions starterOnly/modal.js → starterOnly/javascript/modal.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// DOM Elements
let modalBody = document.querySelector(".modal-body");
let modalbg = document.querySelector(".bground");
let modalBtn = document.querySelectorAll(".modal-btn");
let closeModal = document.getElementsByClassName("close")[0];
Expand All @@ -15,9 +16,10 @@ let conditionsCheckboxes = document.querySelector("input[name='conditions']");
modalFormLaunch();
modalFormClose();
disableSubmitBtn();
// form validation listener

// event listener
document.querySelector('form').addEventListener('change', isFormValid);
// document.querySelector('form').addEventListener('submit', submitForm);
document.querySelector('form').addEventListener('submit', submitForm);
firstName.addEventListener('input', isFirstNameValid);
lastName.addEventListener('input', isLastNameValid);
email.addEventListener('input', isEmailValid);
Expand All @@ -29,7 +31,7 @@ for (checkbox of locationCheckboxes) {
conditionsCheckboxes.addEventListener('change', isConditionsValid);


// form validation
// functions
function isFirstNameValid () {
let parent = firstName.closest('div');
showError(parent);
Expand Down Expand Up @@ -143,9 +145,31 @@ function isFormValid() {

}

// function submitForm(e) {
// e.preventDefault();
// }
function submitForm(e) {
console.log(e);
e.preventDefault();
document.querySelector('.modal-body').innerHTML = " ";
thankyouMessage();
closeBtn();
}

function thankyouMessage() {
let para = document.createElement("P");
para.innerText = 'Merci ! Votre réservation a été reçue.';
document.querySelector('.modal-body').appendChild(para);
para.style.marginTop = "50px"
}

function closeBtn() {
let btn = document.createElement("BUTTON");
btn.innerHTML = "Fermer";
document.querySelector('.modal-body').appendChild(btn);
btn.className = "btn-submit";
btn.style.marginTop = "50px"
btn.onclick = function() {
modalbg.style.display = "none";
};
}

function showError(el) {
el.setAttribute('data-error-visible', true);
Expand Down

0 comments on commit ed858f0

Please sign in to comment.