70 lines
2.4 KiB
JavaScript
70 lines
2.4 KiB
JavaScript
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// Navbar shrink on scroll
|
|
const navbar = document.querySelector('.navbar');
|
|
if (navbar) {
|
|
window.addEventListener('scroll', () => {
|
|
if (window.scrollY > 50) {
|
|
navbar.classList.add('scrolled');
|
|
} else {
|
|
navbar.classList.remove('scrolled');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Smooth scroll for anchor links
|
|
document.querySelectorAll('a.smooth-scroll[href^="#"]').forEach(anchor => {
|
|
anchor.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
const targetId = this.getAttribute('href');
|
|
const targetElement = document.querySelector(targetId);
|
|
if(targetElement){
|
|
targetElement.scrollIntoView({ behavior: 'smooth' });
|
|
}
|
|
});
|
|
});
|
|
|
|
// Pricing Toggle
|
|
const pricingToggle = document.getElementById('pricingToggle');
|
|
if(pricingToggle) {
|
|
pricingToggle.addEventListener('change', function () {
|
|
const isYearly = this.checked;
|
|
document.querySelectorAll('.price-monthly').forEach(p => p.style.display = isYearly ? 'none' : 'block');
|
|
document.querySelectorAll('.price-yearly').forEach(p => p.style.display = isYearly ? 'block' : 'none');
|
|
});
|
|
}
|
|
|
|
// Lead Form Validation
|
|
const leadForm = document.getElementById('leadForm');
|
|
if (leadForm) {
|
|
leadForm.addEventListener('submit', function (e) {
|
|
let isValid = true;
|
|
const name = document.getElementById('name');
|
|
const email = document.getElementById('email');
|
|
const message = document.getElementById('message');
|
|
|
|
// Reset validation
|
|
[name, email, message].forEach(el => {
|
|
el.classList.remove('is-invalid');
|
|
});
|
|
|
|
if (name.value.trim() === '') {
|
|
name.classList.add('is-invalid');
|
|
isValid = false;
|
|
}
|
|
if (email.value.trim() === '' || !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(email.value)) {
|
|
email.classList.add('is-invalid');
|
|
isValid = false;
|
|
}
|
|
if (message.value.trim() === '') {
|
|
message.classList.add('is-invalid');
|
|
isValid = false;
|
|
}
|
|
|
|
if (!isValid) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
});
|