WEBLEB
होम
संपादक
लॉग इन करें
Pro
हिंदी
English
Français
Español
Português
Deutsch
Italiano
हिंदी
HTML
CSS
JS
Futuristic Credit Card
•••• •••• •••• ••••
CARD HOLDER
YOUR NAME
EXPIRES
MM/YY
CVV
•••
This card is property of the issuing bank. Use subject to cardholder agreement.
Payment Details
C
a
r
d
N
u
m
b
e
r
C
a
r
d
H
o
l
d
e
r
E
x
p
i
r
y
D
a
t
e
C
V
V
Process Payment
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Rajdhani', sans-serif; } body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #050816 0%, #0a0a2e 100%); padding: 20px; overflow-x: hidden; } .container { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; max-width: 1000px; gap: 50px; padding: 20px; } @media (min-width: 768px) { .container { flex-direction: row; align-items: flex-start; } } /* Card styles */ .card-wrapper { perspective: 1000px; width: 350px; height: 220px; position: relative; margin-bottom: 30px; } .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); } .card.flipped { transform: rotateY(180deg); } .card-front, .card-back { width: 100%; height: 100%; position: absolute; backface-visibility: hidden; border-radius: 20px; overflow: hidden; padding: 25px; } .card-front { background: linear-gradient(45deg, rgba(15, 23, 42, 0.9), rgba(23, 42, 69, 0.8)); display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 0 10px rgba(8, 145, 178, 0.5), 0 0 30px rgba(8, 145, 178, 0.2); border: 1px solid rgba(8, 145, 178, 0.3); } .card-back { background: linear-gradient(45deg, rgba(15, 23, 42, 0.9), rgba(23, 42, 69, 0.8)); transform: rotateY(180deg); display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 0 10px rgba(8, 145, 178, 0.5), 0 0 30px rgba(8, 145, 178, 0.2); border: 1px solid rgba(8, 145, 178, 0.3); } .holographic-element { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient( 125deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 225, 255, 0.05) 25%, rgba(255, 0, 255, 0.05) 50%, rgba(0, 225, 255, 0.05) 75%, rgba(255, 255, 255, 0.05) 100% ); opacity: 0.3; pointer-events: none; z-index: 1; border-radius: 20px; } .circuit-lines { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-image: linear-gradient(90deg, transparent 49%, rgba(8, 145, 178, 0.2) 50%, transparent 51%), linear-gradient(180deg, transparent 49%, rgba(8, 145, 178, 0.2) 50%, transparent 51%); background-size: 40px 40px; opacity: 0.1; pointer-events: none; z-index: 0; border-radius: 20px; } /* Logo */ .logo { position: absolute; top: 20px; right: 20px; z-index: 2; } .logo svg { height: 48px; width: 54px; filter: drop-shadow(0 0 5px rgba(8, 145, 178, 0.8)); } /* Chip */ .chip-container { position: relative; width: 50px; height: 40px; margin-bottom: 30px; z-index: 2; } .chip { width: 100%; height: 100%; background: linear-gradient(135deg, #e6b400, #ffd700); border-radius: 8px; position: relative; overflow: hidden; } .chip::before { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%; height: 80%; background: linear-gradient(90deg, transparent 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(0deg, transparent 50%, rgba(0, 0, 0, 0.1) 50%); background-size: 10px 10px; border-radius: 4px; } .chip-glow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 8px; box-shadow: 0 0 15px rgba(230, 180, 0, 0.7); animation: pulse 2s infinite alternate; opacity: 0.7; } /* Card Number */ .card-number { margin-bottom: 20px; z-index: 2; position: relative; } #card-num-display { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; letter-spacing: 4px; color: #fff; text-shadow: 0 0 5px rgba(8, 145, 178, 0.8); } /* Card Details */ .card-details { display: flex; justify-content: space-between; z-index: 2; position: relative; } .holder-name, .expiry-date { display: flex; flex-direction: column; } .holder-name label, .expiry-date label { font-size: 0.7rem; color: rgba(255, 255, 255, 0.7); margin-bottom: 5px; letter-spacing: 1px; } #card-holder-display, #expiry-display { font-family: 'Orbitron', sans-serif; font-size: 1rem; color: #fff; text-shadow: 0 0 5px rgba(8, 145, 178, 0.8); } /* Card Back */ .magnetic-strip { width: 100%; height: 40px; background: linear-gradient(to right, #111, #333, #111); margin: 20px 0; } .signature-strip { background: rgba(255, 255, 255, 0.1); height: 40px; display: flex; align-items: center; justify-content: flex-end; padding: 0 10px; border-radius: 4px; } .cvv-container { display: flex; flex-direction: column; align-items: flex-end; } .cvv-container label { font-size: 0.6rem; color: rgba(255, 255, 255, 0.7); margin-bottom: 3px; } #cvv-display { font-family: 'Orbitron', sans-serif; font-size: 1rem; color: #fff; letter-spacing: 2px; } .back-info { font-size: 0.6rem; color: rgba(255, 255, 255, 0.5); text-align: center; margin-top: 20px; line-height: 1.2; } /* Form Styles */ .form-container { background: rgba(15, 23, 42, 0.7); padding: 30px; border-radius: 15px; width: 100%; max-width: 400px; backdrop-filter: blur(10px); border: 1px solid rgba(8, 145, 178, 0.3); box-shadow: 0 0 20px rgba(8, 145, 178, 0.2); } h2 { color: #fff; text-align: center; margin-bottom: 30px; font-family: 'Orbitron', sans-serif; letter-spacing: 1px; text-shadow: 0 0 5px rgba(8, 145, 178, 0.8); } .form-row { display: flex; gap: 20px; margin-bottom: 20px; } .half-width { width: calc(50% - 10px); } .wave-group { position: relative; margin-bottom: 30px; width: 100%; } .wave-group .input { font-size: 16px; padding: 10px 10px 10px 5px; display: block; width: 100%; border: none; border-bottom: 1px solid #515151; background: transparent; color: #fff; font-family: 'Rajdhani', sans-serif; } .wave-group .input:focus { outline: none; } .wave-group .label { color: #999; font-size: 18px; font-weight: normal; position: absolute; pointer-events: none; left: 5px; top: 10px; display: flex; } .wave-group .label-char { transition: 0.2s ease all; transition-delay: calc(var(--index) * 0.05s); } .wave-group .input:focus ~ label .label-char, .wave-group .input:valid ~ label .label-char { transform: translateY(-20px); font-size: 14px; color: #06B6D4; } .wave-group .bar { position: relative; display: block; width: 100%; } .wave-group .bar:before, .wave-group .bar:after { content: ""; height: 2px; width: 0; bottom: 1px; position: absolute; background: #06B6D4; transition: 0.2s ease all; } .wave-group .bar:before { left: 50%; } .wave-group .bar:after { right: 50%; } .wave-group .input:focus ~ .bar:before, .wave-group .input:focus ~ .bar:after { width: 50%; } .submit-btn { width: 100%; padding: 12px; background: rgba(8, 145, 178, 0.2); color: #fff; border: 1px solid rgba(8, 145, 178, 0.5); border-radius: 30px; cursor: pointer; font-family: 'Orbitron', sans-serif; font-size: 16px; position: relative; overflow: hidden; transition: all 0.3s ease; letter-spacing: 1px; margin-top: 10px; } .submit-btn:hover { background: rgba(8, 145, 178, 0.4); } .btn-glow { position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient( 90deg, transparent, rgba(8, 145, 178, 0.3), transparent ); transition: 0.5s; } .submit-btn:hover .btn-glow { left: 100%; } /* Animations */ @keyframes pulse { 0% { opacity: 0.5; box-shadow: 0 0 5px rgba(230, 180, 0, 0.5); } 100% { opacity: 0.8; box-shadow: 0 0 15px rgba(230, 180, 0, 0.8); } } ::selection { background-color: rgba(8, 145, 178, 0.3); color: #fff; }
document.addEventListener('DOMContentLoaded', function() { // DOM Elements const cardElement = document.querySelector('.card'); const cardNumberInput = document.getElementById('card-number'); const cardHolderInput = document.getElementById('card-holder'); const expiryDateInput = document.getElementById('expiry-date'); const cvvInput = document.getElementById('cvv'); const cardNumberDisplay = document.getElementById('card-num-display'); const cardHolderDisplay = document.getElementById('card-holder-display'); const expiryDisplay = document.getElementById('expiry-display'); const cvvDisplay = document.getElementById('cvv-display'); const form = document.getElementById('credit-card-form'); // Format credit card number with spaces cardNumberInput.addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); // Add spaces after every 4 digits if (value.length > 0) { value = value.match(new RegExp('.{1,4}', 'g')).join(' '); } // Update input value with formatted number e.target.value = value; // Update display on card if (value.length > 0) { cardNumberDisplay.textContent = value; } else { cardNumberDisplay.textContent = '•••• •••• •••• ••••'; } // Detect card type detectCardType(value.replace(/\s/g, '')); }); // Format expiry date with slash expiryDateInput.addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); if (value.length > 2) { value = value.substring(0, 2) + '/' + value.substring(2, 4); } e.target.value = value; // Update display on card if (value.length > 0) { expiryDisplay.textContent = value; } else { expiryDisplay.textContent = 'MM/YY'; } }); // Card holder name input cardHolderInput.addEventListener('input', function(e) { let value = e.target.value; // Update display on card if (value.length > 0) { cardHolderDisplay.textContent = value.toUpperCase(); } else { cardHolderDisplay.textContent = 'YOUR NAME'; } }); // CVV input cvvInput.addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); e.target.value = value; // Update display on card if (value.length > 0) { cvvDisplay.textContent = value; } else { cvvDisplay.textContent = '•••'; } }); // Flip card on CVV focus cvvInput.addEventListener('focus', function() { cardElement.classList.add('flipped'); }); cvvInput.addEventListener('blur', function() { cardElement.classList.remove('flipped'); }); // Detect card type based on first few digits function detectCardType(number) { // Visa starts with 4 if (number.startsWith('4')) { updateCardLogo('visa'); } // MasterCard starts with 51-55 or 2221-2720 else if (/^5[1-5]/.test(number) || (/^2/.test(number) && parseInt(number.substring(0, 4)) >= 2221 && parseInt(number.substring(0, 4)) <= 2720)) { updateCardLogo('mastercard'); } // Default to Visa else { updateCardLogo('visa'); } } // Update card logo based on detected type function updateCardLogo(type) { const logoSvg = document.querySelector('.logo svg'); if (type === 'mastercard') { logoSvg.innerHTML = `
`; } else { // Default to Visa logoSvg.innerHTML = `
`; } } // Handle form submission form.addEventListener('submit', function(e) { e.preventDefault(); // Basic validation if (!validateForm()) { showError('Please fill all fields correctly'); return; } // Simulate processing with loading animation const submitBtn = document.querySelector('.submit-btn'); submitBtn.innerHTML = '
Processing...
'; submitBtn.disabled = true; setTimeout(() => { // Simulate successful payment submitBtn.innerHTML = '
Payment Successful!
'; submitBtn.style.background = 'rgba(16, 185, 129, 0.4)'; submitBtn.style.borderColor = 'rgba(16, 185, 129, 0.5)'; // Add success pulse animation to card cardElement.style.boxShadow = '0 0 20px rgba(16, 185, 129, 0.6)'; // Reset form after delay setTimeout(() => { form.reset(); submitBtn.innerHTML = '
Process Payment
'; submitBtn.style.background = ''; submitBtn.style.borderColor = ''; submitBtn.disabled = false; cardElement.style.boxShadow = ''; // Reset card displays cardNumberDisplay.textContent = '•••• •••• •••• ••••'; cardHolderDisplay.textContent = 'YOUR NAME'; expiryDisplay.textContent = 'MM/YY'; cvvDisplay.textContent = '•••'; }, 3000); }, 2000); }); // Basic form validation function validateForm() { // Check card number (should be 16 digits) const cardNumber = cardNumberInput.value.replace(/\s/g, ''); if (cardNumber.length !== 16 || !/^\d+$/.test(cardNumber)) { return false; } // Check card holder (should not be empty) if (cardHolderInput.value.trim() === '') { return false; } // Check expiry date (format MM/YY) const expiry = expiryDateInput.value; if (!/^\d{2}\/\d{2}$/.test(expiry)) { return false; } // Validate month (01-12) const month = parseInt(expiry.split('/')[0]); if (month < 1 || month > 12) { return false; } // Check CVV (should be 3 digits) if (cvvInput.value.length !== 3 || !/^\d+$/.test(cvvInput.value)) { return false; } return true; } // Show error message function showError(message) { // Implementation for error display alert(message); } // Add interactive behavior to card const card = document.querySelector('.card-wrapper'); // 3D tilt effect on mousemove card.addEventListener('mousemove', function(e) { const rect = card.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; const centerX = rect.width / 2; const centerY = rect.height / 2; const rotateX = (y - centerY) / 10; const rotateY = -(x - centerX) / 10; cardElement.style.transform = `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`; // Update holographic effect based on mouse position const holographic = document.querySelector('.holographic-element'); holographic.style.backgroundPosition = `${(x / rect.width) * 100}% ${(y / rect.height) * 100}%`; }); // Reset transform on mouseout card.addEventListener('mouseleave', function() { cardElement.style.transform = 'rotateX(0) rotateY(0)'; // Don't reset if card is flipped if (cardElement.classList.contains('flipped')) { cardElement.style.transform = 'rotateY(180deg)'; } }); }); // Remove any error styles const errorElements = document.querySelectorAll('.error'); errorElements.forEach(element => element.classList.remove('error')); }); });
Validating your code, please wait...
HTML
CSS
JS
Futuristic Credit Card
•••• •••• •••• ••••
CARD HOLDER
YOUR NAME
EXPIRES
MM/YY
CVV
•••
This card is property of the issuing bank. Use subject to cardholder agreement.
Payment Details
C
a
r
d
N
u
m
b
e
r
C
a
r
d
H
o
l
d
e
r
E
x
p
i
r
y
D
a
t
e
C
V
V
Process Payment
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Rajdhani', sans-serif; } body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #050816 0%, #0a0a2e 100%); padding: 20px; overflow-x: hidden; } .container { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; max-width: 1000px; gap: 50px; padding: 20px; } @media (min-width: 768px) { .container { flex-direction: row; align-items: flex-start; } } /* Card styles */ .card-wrapper { perspective: 1000px; width: 350px; height: 220px; position: relative; margin-bottom: 30px; } .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); } .card.flipped { transform: rotateY(180deg); } .card-front, .card-back { width: 100%; height: 100%; position: absolute; backface-visibility: hidden; border-radius: 20px; overflow: hidden; padding: 25px; } .card-front { background: linear-gradient(45deg, rgba(15, 23, 42, 0.9), rgba(23, 42, 69, 0.8)); display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 0 10px rgba(8, 145, 178, 0.5), 0 0 30px rgba(8, 145, 178, 0.2); border: 1px solid rgba(8, 145, 178, 0.3); } .card-back { background: linear-gradient(45deg, rgba(15, 23, 42, 0.9), rgba(23, 42, 69, 0.8)); transform: rotateY(180deg); display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 0 10px rgba(8, 145, 178, 0.5), 0 0 30px rgba(8, 145, 178, 0.2); border: 1px solid rgba(8, 145, 178, 0.3); } .holographic-element { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient( 125deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 225, 255, 0.05) 25%, rgba(255, 0, 255, 0.05) 50%, rgba(0, 225, 255, 0.05) 75%, rgba(255, 255, 255, 0.05) 100% ); opacity: 0.3; pointer-events: none; z-index: 1; border-radius: 20px; } .circuit-lines { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-image: linear-gradient(90deg, transparent 49%, rgba(8, 145, 178, 0.2) 50%, transparent 51%), linear-gradient(180deg, transparent 49%, rgba(8, 145, 178, 0.2) 50%, transparent 51%); background-size: 40px 40px; opacity: 0.1; pointer-events: none; z-index: 0; border-radius: 20px; } /* Logo */ .logo { position: absolute; top: 20px; right: 20px; z-index: 2; } .logo svg { height: 48px; width: 54px; filter: drop-shadow(0 0 5px rgba(8, 145, 178, 0.8)); } /* Chip */ .chip-container { position: relative; width: 50px; height: 40px; margin-bottom: 30px; z-index: 2; } .chip { width: 100%; height: 100%; background: linear-gradient(135deg, #e6b400, #ffd700); border-radius: 8px; position: relative; overflow: hidden; } .chip::before { content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 80%; height: 80%; background: linear-gradient(90deg, transparent 50%, rgba(0, 0, 0, 0.1) 50%), linear-gradient(0deg, transparent 50%, rgba(0, 0, 0, 0.1) 50%); background-size: 10px 10px; border-radius: 4px; } .chip-glow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 8px; box-shadow: 0 0 15px rgba(230, 180, 0, 0.7); animation: pulse 2s infinite alternate; opacity: 0.7; } /* Card Number */ .card-number { margin-bottom: 20px; z-index: 2; position: relative; } #card-num-display { font-family: 'Orbitron', sans-serif; font-size: 1.5rem; letter-spacing: 4px; color: #fff; text-shadow: 0 0 5px rgba(8, 145, 178, 0.8); } /* Card Details */ .card-details { display: flex; justify-content: space-between; z-index: 2; position: relative; } .holder-name, .expiry-date { display: flex; flex-direction: column; } .holder-name label, .expiry-date label { font-size: 0.7rem; color: rgba(255, 255, 255, 0.7); margin-bottom: 5px; letter-spacing: 1px; } #card-holder-display, #expiry-display { font-family: 'Orbitron', sans-serif; font-size: 1rem; color: #fff; text-shadow: 0 0 5px rgba(8, 145, 178, 0.8); } /* Card Back */ .magnetic-strip { width: 100%; height: 40px; background: linear-gradient(to right, #111, #333, #111); margin: 20px 0; } .signature-strip { background: rgba(255, 255, 255, 0.1); height: 40px; display: flex; align-items: center; justify-content: flex-end; padding: 0 10px; border-radius: 4px; } .cvv-container { display: flex; flex-direction: column; align-items: flex-end; } .cvv-container label { font-size: 0.6rem; color: rgba(255, 255, 255, 0.7); margin-bottom: 3px; } #cvv-display { font-family: 'Orbitron', sans-serif; font-size: 1rem; color: #fff; letter-spacing: 2px; } .back-info { font-size: 0.6rem; color: rgba(255, 255, 255, 0.5); text-align: center; margin-top: 20px; line-height: 1.2; } /* Form Styles */ .form-container { background: rgba(15, 23, 42, 0.7); padding: 30px; border-radius: 15px; width: 100%; max-width: 400px; backdrop-filter: blur(10px); border: 1px solid rgba(8, 145, 178, 0.3); box-shadow: 0 0 20px rgba(8, 145, 178, 0.2); } h2 { color: #fff; text-align: center; margin-bottom: 30px; font-family: 'Orbitron', sans-serif; letter-spacing: 1px; text-shadow: 0 0 5px rgba(8, 145, 178, 0.8); } .form-row { display: flex; gap: 20px; margin-bottom: 20px; } .half-width { width: calc(50% - 10px); } .wave-group { position: relative; margin-bottom: 30px; width: 100%; } .wave-group .input { font-size: 16px; padding: 10px 10px 10px 5px; display: block; width: 100%; border: none; border-bottom: 1px solid #515151; background: transparent; color: #fff; font-family: 'Rajdhani', sans-serif; } .wave-group .input:focus { outline: none; } .wave-group .label { color: #999; font-size: 18px; font-weight: normal; position: absolute; pointer-events: none; left: 5px; top: 10px; display: flex; } .wave-group .label-char { transition: 0.2s ease all; transition-delay: calc(var(--index) * 0.05s); } .wave-group .input:focus ~ label .label-char, .wave-group .input:valid ~ label .label-char { transform: translateY(-20px); font-size: 14px; color: #06B6D4; } .wave-group .bar { position: relative; display: block; width: 100%; } .wave-group .bar:before, .wave-group .bar:after { content: ""; height: 2px; width: 0; bottom: 1px; position: absolute; background: #06B6D4; transition: 0.2s ease all; } .wave-group .bar:before { left: 50%; } .wave-group .bar:after { right: 50%; } .wave-group .input:focus ~ .bar:before, .wave-group .input:focus ~ .bar:after { width: 50%; } .submit-btn { width: 100%; padding: 12px; background: rgba(8, 145, 178, 0.2); color: #fff; border: 1px solid rgba(8, 145, 178, 0.5); border-radius: 30px; cursor: pointer; font-family: 'Orbitron', sans-serif; font-size: 16px; position: relative; overflow: hidden; transition: all 0.3s ease; letter-spacing: 1px; margin-top: 10px; } .submit-btn:hover { background: rgba(8, 145, 178, 0.4); } .btn-glow { position: absolute; top: 0; left: -100%; width: 100%; height: 100%; background: linear-gradient( 90deg, transparent, rgba(8, 145, 178, 0.3), transparent ); transition: 0.5s; } .submit-btn:hover .btn-glow { left: 100%; } /* Animations */ @keyframes pulse { 0% { opacity: 0.5; box-shadow: 0 0 5px rgba(230, 180, 0, 0.5); } 100% { opacity: 0.8; box-shadow: 0 0 15px rgba(230, 180, 0, 0.8); } } ::selection { background-color: rgba(8, 145, 178, 0.3); color: #fff; }
document.addEventListener('DOMContentLoaded', function() { // DOM Elements const cardElement = document.querySelector('.card'); const cardNumberInput = document.getElementById('card-number'); const cardHolderInput = document.getElementById('card-holder'); const expiryDateInput = document.getElementById('expiry-date'); const cvvInput = document.getElementById('cvv'); const cardNumberDisplay = document.getElementById('card-num-display'); const cardHolderDisplay = document.getElementById('card-holder-display'); const expiryDisplay = document.getElementById('expiry-display'); const cvvDisplay = document.getElementById('cvv-display'); const form = document.getElementById('credit-card-form'); // Format credit card number with spaces cardNumberInput.addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); // Add spaces after every 4 digits if (value.length > 0) { value = value.match(new RegExp('.{1,4}', 'g')).join(' '); } // Update input value with formatted number e.target.value = value; // Update display on card if (value.length > 0) { cardNumberDisplay.textContent = value; } else { cardNumberDisplay.textContent = '•••• •••• •••• ••••'; } // Detect card type detectCardType(value.replace(/\s/g, '')); }); // Format expiry date with slash expiryDateInput.addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); if (value.length > 2) { value = value.substring(0, 2) + '/' + value.substring(2, 4); } e.target.value = value; // Update display on card if (value.length > 0) { expiryDisplay.textContent = value; } else { expiryDisplay.textContent = 'MM/YY'; } }); // Card holder name input cardHolderInput.addEventListener('input', function(e) { let value = e.target.value; // Update display on card if (value.length > 0) { cardHolderDisplay.textContent = value.toUpperCase(); } else { cardHolderDisplay.textContent = 'YOUR NAME'; } }); // CVV input cvvInput.addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); e.target.value = value; // Update display on card if (value.length > 0) { cvvDisplay.textContent = value; } else { cvvDisplay.textContent = '•••'; } }); // Flip card on CVV focus cvvInput.addEventListener('focus', function() { cardElement.classList.add('flipped'); }); cvvInput.addEventListener('blur', function() { cardElement.classList.remove('flipped'); }); // Detect card type based on first few digits function detectCardType(number) { // Visa starts with 4 if (number.startsWith('4')) { updateCardLogo('visa'); } // MasterCard starts with 51-55 or 2221-2720 else if (/^5[1-5]/.test(number) || (/^2/.test(number) && parseInt(number.substring(0, 4)) >= 2221 && parseInt(number.substring(0, 4)) <= 2720)) { updateCardLogo('mastercard'); } // Default to Visa else { updateCardLogo('visa'); } } // Update card logo based on detected type function updateCardLogo(type) { const logoSvg = document.querySelector('.logo svg'); if (type === 'mastercard') { logoSvg.innerHTML = `
`; } else { // Default to Visa logoSvg.innerHTML = `
`; } } // Handle form submission form.addEventListener('submit', function(e) { e.preventDefault(); // Basic validation if (!validateForm()) { showError('Please fill all fields correctly'); return; } // Simulate processing with loading animation const submitBtn = document.querySelector('.submit-btn'); submitBtn.innerHTML = '
Processing...
'; submitBtn.disabled = true; setTimeout(() => { // Simulate successful payment submitBtn.innerHTML = '
Payment Successful!
'; submitBtn.style.background = 'rgba(16, 185, 129, 0.4)'; submitBtn.style.borderColor = 'rgba(16, 185, 129, 0.5)'; // Add success pulse animation to card cardElement.style.boxShadow = '0 0 20px rgba(16, 185, 129, 0.6)'; // Reset form after delay setTimeout(() => { form.reset(); submitBtn.innerHTML = '
Process Payment
'; submitBtn.style.background = ''; submitBtn.style.borderColor = ''; submitBtn.disabled = false; cardElement.style.boxShadow = ''; // Reset card displays cardNumberDisplay.textContent = '•••• •••• •••• ••••'; cardHolderDisplay.textContent = 'YOUR NAME'; expiryDisplay.textContent = 'MM/YY'; cvvDisplay.textContent = '•••'; }, 3000); }, 2000); }); // Basic form validation function validateForm() { // Check card number (should be 16 digits) const cardNumber = cardNumberInput.value.replace(/\s/g, ''); if (cardNumber.length !== 16 || !/^\d+$/.test(cardNumber)) { return false; } // Check card holder (should not be empty) if (cardHolderInput.value.trim() === '') { return false; } // Check expiry date (format MM/YY) const expiry = expiryDateInput.value; if (!/^\d{2}\/\d{2}$/.test(expiry)) { return false; } // Validate month (01-12) const month = parseInt(expiry.split('/')[0]); if (month < 1 || month > 12) { return false; } // Check CVV (should be 3 digits) if (cvvInput.value.length !== 3 || !/^\d+$/.test(cvvInput.value)) { return false; } return true; } // Show error message function showError(message) { // Implementation for error display alert(message); } // Add interactive behavior to card const card = document.querySelector('.card-wrapper'); // 3D tilt effect on mousemove card.addEventListener('mousemove', function(e) { const rect = card.getBoundingClientRect(); const x = e.clientX - rect.left; const y = e.clientY - rect.top; const centerX = rect.width / 2; const centerY = rect.height / 2; const rotateX = (y - centerY) / 10; const rotateY = -(x - centerX) / 10; cardElement.style.transform = `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`; // Update holographic effect based on mouse position const holographic = document.querySelector('.holographic-element'); holographic.style.backgroundPosition = `${(x / rect.width) * 100}% ${(y / rect.height) * 100}%`; }); // Reset transform on mouseout card.addEventListener('mouseleave', function() { cardElement.style.transform = 'rotateX(0) rotateY(0)'; // Don't reset if card is flipped if (cardElement.classList.contains('flipped')) { cardElement.style.transform = 'rotateY(180deg)'; } }); }); // Remove any error styles const errorElements = document.querySelectorAll('.error'); errorElements.forEach(element => element.classList.remove('error')); }); });