Digital Signature Tool
Digital Signature Tool
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
background-color: white;
border-radius: 10px;
padding: 30px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
width: 80%;
max-width: 800px;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
color: #333;
}
.signature-box {
margin: 20px auto;
background-color: #fafafa;
border: 2px solid #ddd;
border-radius: 8px;
position: relative;
overflow: hidden;
}
.signature-pad {
border: none;
background-color: transparent;
}
.buttons {
margin-top: 20px;
}
.btn {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
font-size: 16px;
margin: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
.btn:hover {
background-color: #45a049;
}
.signature-result {
margin-top: 20px;
padding: 15px;
background-color: #f4f4f4;
border-radius: 8px;
border: 1px solid #ddd;
min-height: 100px;
}
const canvas = document.getElementById('signature-pad');
const signaturePad = new SignaturePad(canvas);
const clearButton = document.getElementById('clear-btn');
const saveButton = document.getElementById('save-btn');
const resultDiv = document.getElementById('signature-result');
// Clear the signature pad
clearButton.addEventListener('click', () => {
signaturePad.clear();
resultDiv.innerHTML = '';
});
// Save the signature
saveButton.addEventListener('click', () => {
if (signaturePad.isEmpty()) {
alert('Please provide a signature first!');
} else {
const dataUrl = signaturePad.toDataURL();
resultDiv.innerHTML = `
Your Signature:

`;
}
});