-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (19 loc) · 792 Bytes
/
Copy pathscript.js
File metadata and controls
21 lines (19 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const qrInput = document.getElementById("url-input");
const generateBtn = document.getElementById("generate-btn");
const qrContainer = document.getElementById("qr-code-container");
const qrImg = document.getElementById("qr-code");
const errorMsg = document.getElementById("error-message");
function generateQRCode() {
const qrValue = qrInput.value;
if(qrValue.trim() === "") {
errorMsg.textContent = "Please enter a valid URL or text.";
errorMsg.classList.add("show-error");
qrImg.classList.remove("show-img");
return;
}
errorMsg.classList.remove("show-error");
qrImg.src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${qrValue}`;
qrImg.alt = qrValue;
qrImg.classList.add("show-img");
}
generateBtn.addEventListener("click", generateQRCode);