forked from OpenClassrooms-Student-Center/GameOn-website-FR
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue OpenClassrooms-Student-Center#2 validation for each input
- Loading branch information
Showing
3 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function firstValidation() { | ||
let inputValue = document.getElementById("first").value; | ||
if (inputValue !== null && inputValue.length > 2) return true; | ||
else return false; | ||
} | ||
|
||
function lastValidation() { | ||
let inputValue = document.getElementById("last").value; | ||
if (inputValue !== null && inputValue.length > 2) return true; | ||
else return false; | ||
} | ||
|
||
function emailValidation() { | ||
let regex = /^([a-z0-9_\.-]+\@[\da-z\.-]+\.[a-z\.]{2,6})$/; | ||
let inputValue = document.getElementById("email").value; | ||
return regex.test(inputValue); | ||
} | ||
|
||
function quantityValidation() { | ||
let regex = /^[0-9]+$/; | ||
let inputValue = document.getElementById("quantity").value; | ||
return regex.test(inputValue); | ||
} | ||
|
||
function locationValidation() { | ||
let radioButtons = document.querySelectorAll(".checkbox-input[type=radio]"); | ||
for(let radio of radioButtons){ | ||
if(radio.checked === true) return true; | ||
} | ||
return false; | ||
} | ||
|
||
function checkboxValidation() { | ||
let inputValue = document.getElementById("checkbox1").checked; | ||
return inputValue; | ||
} | ||
|
||
document | ||
.getElementById("button") | ||
.addEventListener("click", function formValidation(event) { | ||
event.preventDefault(); | ||
console.log(checkboxValidation()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters