Send Us Your Enquiry – Get a Quote for Industrial Water
Treatment Chemicals in Switzerland
// Your WhatsApp number
const whatsappNumber = '+919312871070'; // Your number without '+' or spaces
// Function to validate form
function validateForm() {
let isValid = true;
// Reset error messages
document.querySelectorAll('.error-message').forEach(el => {
el.style.display = 'none';
});
// Validate Name
const name = document.getElementById('name').value.trim();
if (!name) {
document.getElementById('nameError').textContent = 'Please enter your name';
document.getElementById('nameError').style.display = 'block';
isValid = false;
}
// Validate Phone
const phone = document.getElementById('phone').value.trim();
if (!phone) {
document.getElementById('phoneError').textContent = 'Please enter your phone number';
document.getElementById('phoneError').style.display = 'block';
isValid = false;
} else if (!/^[0-9]{10,15}$/.test(phone.replace(/\D/g, ''))) {
document.getElementById('phoneError').textContent = 'Please enter a valid phone number';
document.getElementById('phoneError').style.display = 'block';
isValid = false;
}
// Validate Service
const service = document.getElementById('service').value;
if (!service) {
document.getElementById('serviceError').textContent = 'Please select a service';
document.getElementById('serviceError').style.display = 'block';
isValid = false;
}
// Validate Message
const message = document.getElementById('message').value.trim();
if (!message) {
document.getElementById('messageError').textContent = 'Please enter your message';
document.getElementById('messageError').style.display = 'block';
isValid = false;
}
return isValid;
}
// Function to send data to WhatsApp Web
function sendToWhatsApp(actionType = 'form') {
if (!validateForm()) {
return;
}
const name = document.getElementById('name').value.trim() || 'Name not provided';
const phone = document.getElementById('phone').value.trim() || 'Phone number not provided';
const email = document.getElementById('email').value.trim() || 'Email not provided';
const service = document.getElementById('service').value || 'Service not selected';
const message = document.getElementById('message').value.trim() || 'No message';
// Create WhatsApp message
let whatsappMessage = `New ${actionType === 'form' ? 'Form Submission' : 'Direct Message'}! 👋\n\n`;
whatsappMessage += `*Name:* ${name}\n`;
whatsappMessage += `*Phone:* ${phone}\n`;
whatsappMessage += `*Email:* ${email}\n`;
whatsappMessage += `*Service:* ${service}\n\n`;
whatsappMessage += `*Message:* ${message}\n\n`;
whatsappMessage += `Please contact this person.`;
// WhatsApp Web URL (will open in web.whatsapp.com directly)
const whatsappURL = `https://web.whatsapp.com/send?phone=${whatsappNumber}&text=${encodeURIComponent(whatsappMessage)}`;
// Try to open WhatsApp Web directly
window.open(whatsappURL, '_blank');
// Show success message only for form submission
if (actionType === 'form') {
document.getElementById('successMessage').style.display = 'block';
document.getElementById('enquiryForm').reset();
// Scroll to top
window.scrollTo({ top: 0, behavior: 'smooth' });
// Hide success message after 5 seconds
setTimeout(() => {
document.getElementById('successMessage').style.display = 'none';
}, 5000);
}
}
// Event listeners
document.getElementById('submitBtn').addEventListener('click', function () {
sendToWhatsApp('form');
});
document.getElementById('whatsappBtn').addEventListener('click', function () {
sendToWhatsApp('message');
});
// Form field animations
const inputs = document.querySelectorAll('input, textarea, select');
inputs.forEach(input => {
input.addEventListener('focus', function () {
this.parentNode.style.transform = 'scale(1.02)';
this.parentNode.style.transition = 'transform 0.3s ease';
});
input.addEventListener('blur', function () {
this.parentNode.style.transform = 'scale(1)';
});
});