-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathscript.js
39 lines (24 loc) · 1.09 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const txtInput = document.querySelector(".inputs input"),
checkBtn = document.querySelector(".inputs button"),
infoTxt = document.querySelector(".info-text");
let filterInput;
checkBtn.addEventListener("click", () =>{
infoTxt.style.display = "block";
// splitting user input character and join them in a single line
let reverseInput = filterInput.split("").reverse().join("");
if(filterInput != reverseInput){
return infoTxt.innerHTML = ` No, <span>'${txtInput.value}'</span> isn't a Palindrome!`;
// return console.log("Not Palindrome ");
}
return infoTxt.innerHTML = ` Yes, <span>'${txtInput.value}'</span> It's a Palindrome!`;
// console.log("Yes! Palindrome");
});
txtInput.addEventListener("keyup", () => {
// removing spaces and all special character from entered value
filterInput = txtInput.value.toLowerCase().replace(/[^A-Z0-9]/ig, "");
if(filterInput){
return checkBtn.classList.add("active");
}
checkBtn.classList.remove("active");
infoTxt.style.display = "none";
})