Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Final testing
  • Loading branch information
edksam committed Jul 26, 2020
commit aa0d1419d673afb51a654e7ae73885b686ddd33a
2 changes: 1 addition & 1 deletion Week-2/Homework/mandatory/2-exercises/exercises.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ let people = [
{ name: "Boris", job: "Prime Minister" },
];

// exerciseOne(people);
exerciseOne(people);

let shopping = ["Milk", "Break", "Eggs", "A Dinosaur", "Cake", "Sugar", "Tea"];

Expand Down
59 changes: 20 additions & 39 deletions Week-2/Homework/mandatory/3-project/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ blueBtn.addEventListener("click", function () {
orangeBtn.addEventListener("click", function () {
jumbotron.style.backgroundColor = "#f0ad4e";
donateABikeBtn.style.backgroundColor = "#5751fd";
volunteer.style.backgroundColor = "##31b0d5";
volunteer.style.backgroundColor = "#31b0d5";
volunteer.style.color = "#ffffff";
});

greenBtn.addEventListener("click", function () {
jumbotron.style.backgroundColor = "#87ca8a";
donateABikeBtn.style.backgroundColor = "black";
volunteer.style.backgroundColor = "#8c9c08`";
volunteer.style.backgroundColor = "#8c9c08";
volunteer.style.color = "#ffffff";
});

Expand All @@ -32,54 +32,35 @@ const name = document.querySelector("#example-text-input");
const email = document.querySelector("#exampleInputEmail1");
const describe = document.querySelector("#exampleTextarea");

submitBtn.addEventListener("click", function (event) {
event.preventDefault();

const emailMatch = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
submitBtn.addEventListener("click", function (e) {
e.preventDefault();

//check for email validity
let emailMatch = "@";
// Check for non-empty
if (!email.value.includes(emailMatch) || email.value.length <= 0) {
alert("Please enter a valid email");
email.style.backgroundColor = "red";
}
if (email.value.length <= 0) {
alert("Please enter an email");
alert("Please enter your email");
email.style.backgroundColor = "red";
}

if (name.value.length <= 0) {
alert("Please enter your name");
name.style.backgroundColor = "red";
}

if (describe.value.length <= 0) {
alert("Please enter a description");
alert("Please enter your description");
describe.style.backgroundColor = "red";
}

// if (
// email.value.length >= 0 &&
// name.value.length >= 0 &&
// describe.value.length >= 0
// ) {
// alert("Thank you for filling the form");
// name.value = "";
// email.value = "";
// describe.value = "";
// }

//Email Validation
// if (!email.value.match(emailMatch)) {
// alert("Please enter a valid email");
// email.style.backgroundColor = "yellow";
// } else if (
// email.value.length >= 0 &&
// name.value.length >= 0 &&
// describe.value.length >= 0
// ) {
// alert("Thank you for filling the form");
// name.value = "";
// email.value = "";
// describe.value = "";
// }

if (email.validity.patternMismatch) {
alert("Enter Valid Email");
email.style.backgroundColor = "red";
// check for all fields entered
if (!email.value == "" && !name.value == "" && !describe.value == "") {
alert("Thank you for filling the form");
}

email.value = "";
name.value = "";
describe.value = "";
});