Skip to content
Open
Changes from all commits
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
32 changes: 29 additions & 3 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,35 @@ backspace.addEventListener('click',()=>{
blockInput()
})

// Blocking the inputs after crossing the limit
displayGuessed.addEventListener('input', blockInput)
displayGenerated.addEventListener('input', blockInput)

// Functionality of submit button
submitBtn.addEventListener('click', submitFunction)

// Blocking the inputs after crossing the limit
displayGuessed.addEventListener('input', blockInput)
displayGenerated.addEventListener('input', blockInput)
function submitFunction() {
const generatedPin = displayGenerated.value;
const guessedPin = displayGuessed.value;

if (!guessedPin) {
alert("Please enter your guess before submitting.");
return;
}

if (guessedPin === generatedPin) {
alert("✅ PIN matched successfully!");
// Additional success logic here
} else {
leftTries--;
alert(`❌ Incorrect PIN. Tries left: ${leftTries}`);
if (leftTries <= 0) {
alert("🔒 You have used all attempts. Input blocked.");
blockInput();
}
}

displayGuessed.value = '';
}