-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 985 Bytes
/
script.js
File metadata and controls
24 lines (21 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
document.addEventListener('DOMContentLoaded', function () {
// Get references to the textareas and error output div
var userInput = document.getElementById('userInput');
var comparisonText = document.getElementById('comparisonText');
var errorOutput = document.getElementById('errorOutput');
// Listen for input events on both textareas
userInput.addEventListener('input', compareText);
comparisonText.addEventListener('input', compareText);
// Function to compare text in the textareas
function compareText() {
// Get the text from both textareas
var userText = userInput.value.trim();
var compareText = comparisonText.value.trim();
// Compare the text and display error if they are not similar
if (userText !== compareText) {
errorOutput.textContent = "Texts do not match!";
} else {
errorOutput.textContent = ""; // Clear error message if texts match
}
}
});