-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQR-Code.html
37 lines (36 loc) · 1.1 KB
/
QR-Code.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QR Code generator</title>
<link rel="stylesheet" href="QR-Code.css">
</head>
<body>
<div class="container">
<p>Enter your text or URL</p>
<input type="text" placeholder="Text or URL" id="qrText">
<div id="imgBox">
<img src="" id="qrImage">
</div>
<button onclick="generateQR()">Generate QR Code</button>
</div>
</body>
<script>
let imgBox = document.getElementById('imgBox');
let qrImage = document.getElementById('qrImage');
let qrText = document.getElementById('qrText');
function generateQR() {
if(qrText.value.length > 0){
qrImage.src = "https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=" + qrText.value;
imgBox.classList.add('show-img');
}
else {
qrText.classList.add('error');
setTimeout(()=>{
qrText.classList.remove('error');
}, 1000);
}
}
</script>
</html>