document.getElementById('download-btn').addEventListener('click', function() { const youtubeUrl = document.getElementById('youtube-url').value; const format = document.getElementById('format').value; if (!youtubeUrl.includes('youtube.com')) { alert('Please enter a valid YouTube URL'); return; } // Redirect to download handler window.location.href = `/download.php?url=${encodeURIComponent(youtubeUrl)}&format=${format}`; });