test2 / index.html
ali-ghadimi's picture
Add 3 files
6430b27 verified
Raw History Blame Contribute Delete
16.7 kB
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>فرم ثبت نام</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');
body {
font-family: 'Vazirmatn', sans-serif;
}
.gradient-bg {
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
.input-focus:focus {
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
}
.shake {
animation: shake 0.5s;
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
20%, 40%, 60%, 80% { transform: translateX(5px); }
}
.password-strength {
height: 4px;
transition: all 0.3s ease;
}
.phone-input {
direction: ltr;
text-align: right;
}
</style>
</head>
<body class="min-h-screen bg-gray-50 flex items-center justify-center p-4">
<div class="w-full max-w-md">
<div class="gradient-bg text-white rounded-t-2xl p-6 text-center shadow-lg">
<h1 class="text-3xl font-bold">ثبت نام</h1>
<p class="mt-2 opacity-90">همین حالا به جمع ما بپیوندید</p>
</div>
<div class="bg-white rounded-b-2xl shadow-xl p-8">
<form id="registrationForm" class="space-y-6">
<div class="relative group">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400 group-focus-within:text-indigo-500">
<i class="fas fa-user"></i>
</div>
<input type="text" id="fullname" class="w-full pr-10 pl-4 py-3 rounded-lg border border-gray-300 focus:border-indigo-500 input-focus transition duration-200" placeholder="نام کامل" required>
</div>
<div class="relative group">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400 group-focus-within:text-indigo-500">
<i class="fas fa-envelope"></i>
</div>
<input type="email" id="email" class="w-full pr-10 pl-4 py-3 rounded-lg border border-gray-300 focus:border-indigo-500 input-focus transition duration-200" placeholder="آدرس ایمیل" required>
</div>
<div class="relative group">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400 group-focus-within:text-indigo-500">
<i class="fas fa-phone"></i>
</div>
<input type="tel" id="phone" class="w-full pr-10 pl-4 py-3 rounded-lg border border-gray-300 focus:border-indigo-500 input-focus transition duration-200 phone-input" placeholder="شماره تلفن" dir="ltr" required>
</div>
<div class="relative group">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400 group-focus-within:text-indigo-500">
<i class="fas fa-lock"></i>
</div>
<input type="password" id="password" class="w-full pr-10 pl-4 py-3 rounded-lg border border-gray-300 focus:border-indigo-500 input-focus transition duration-200" placeholder="رمز عبور" required>
<button type="button" class="absolute right-3 top-3 text-gray-400 hover:text-gray-600" id="togglePassword">
<i class="fas fa-eye"></i>
</button>
<div class="flex mt-1 space-x-1 space-x-reverse">
<div id="strength-1" class="password-strength w-1/4 bg-gray-200 rounded-full"></div>
<div id="strength-2" class="password-strength w-1/4 bg-gray-200 rounded-full"></div>
<div id="strength-3" class="password-strength w-1/4 bg-gray-200 rounded-full"></div>
<div id="strength-4" class="password-strength w-1/4 bg-gray-200 rounded-full"></div>
</div>
<p class="text-xs text-gray-500 mt-1 text-right" id="password-hint">حداقل ۸ کاراکتر با ترکیبی از حروف، اعداد و نمادها</p>
</div>
<div class="relative group">
<div class="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none text-gray-400 group-focus-within:text-indigo-500">
<i class="fas fa-lock"></i>
</div>
<input type="password" id="confirmPassword" class="w-full pr-10 pl-4 py-3 rounded-lg border border-gray-300 focus:border-indigo-500 input-focus transition duration-200" placeholder="تکرار رمز عبور" required>
</div>
<div class="flex items-center">
<input type="checkbox" id="terms" class="w-4 h-4 text-indigo-600 rounded focus:ring-indigo-500 ml-2">
<label for="terms" class="text-sm text-gray-600">
با <a href="#" class="text-indigo-600 hover:underline">شرایط و ضوابط</a> و <a href="#" class="text-indigo-600 hover:underline">سیاست حفظ حریم خصوصی</a> موافقم
</label>
</div>
<button type="submit" class="w-full gradient-bg text-white py-3 px-4 rounded-lg font-medium hover:opacity-90 transition duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 shadow-md">
ثبت نام
</button>
<div class="text-center text-sm text-gray-600">
حساب کاربری دارید؟ <a href="#" class="text-indigo-600 font-medium hover:underline">ورود</a>
</div>
</form>
<div class="mt-6">
<div class="relative">
<div class="absolute inset-0 flex items-center">
<div class="w-full border-t border-gray-300"></div>
</div>
<div class="relative flex justify-center text-sm">
<span class="px-2 bg-white text-gray-500">یا ثبت نام با</span>
</div>
</div>
<div class="mt-6 grid grid-cols-3 gap-3">
<button class="w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<i class="fab fa-google text-red-500"></i>
</button>
<button class="w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<i class="fab fa-facebook-f text-blue-600"></i>
</button>
<button class="w-full inline-flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
<i class="fab fa-twitter text-blue-400"></i>
</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('registrationForm');
const togglePassword = document.getElementById('togglePassword');
const passwordInput = document.getElementById('password');
const confirmPasswordInput = document.getElementById('confirmPassword');
const phoneInput = document.getElementById('phone');
const strengthBars = [
document.getElementById('strength-1'),
document.getElementById('strength-2'),
document.getElementById('strength-3'),
document.getElementById('strength-4')
];
const passwordHint = document.getElementById('password-hint');
// Toggle password visibility
togglePassword.addEventListener('click', function() {
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
passwordInput.setAttribute('type', type);
this.innerHTML = type === 'password' ? '<i class="fas fa-eye"></i>' : '<i class="fas fa-eye-slash"></i>';
});
// Format phone number input
phoneInput.addEventListener('input', function(e) {
let value = this.value.replace(/\D/g, '');
if (value.length > 0) {
value = value.substring(0, 11);
}
this.value = value;
});
// Password strength indicator
passwordInput.addEventListener('input', function() {
const password = this.value;
let strength = 0;
// Check password length
if (password.length >= 8) strength++;
if (password.length >= 12) strength++;
// Check for mixed case
if (/[a-z]/.test(password) && /[A-Z]/.test(password)) strength++;
// Check for numbers
if (/\d/.test(password)) strength++;
// Check for special characters
if (/[^a-zA-Z0-9]/.test(password)) strength++;
// Cap strength at 4
strength = Math.min(strength, 4);
// Update strength bars
strengthBars.forEach((bar, index) => {
if (index < strength) {
let color;
if (strength <= 2) color = 'bg-red-500';
else if (strength === 3) color = 'bg-yellow-500';
else color = 'bg-green-500';
bar.className = `password-strength w-1/4 ${color} rounded-full`;
} else {
bar.className = 'password-strength w-1/4 bg-gray-200 rounded-full';
}
});
// Update hint text
if (password.length === 0) {
passwordHint.textContent = 'حداقل ۸ کاراکتر با ترکیبی از حروف، اعداد و نمادها';
passwordHint.className = 'text-xs text-gray-500 mt-1 text-right';
} else if (strength <= 2) {
passwordHint.textContent = 'رمز عبور ضعیف. لطفاً از حروف، اعداد و نمادها استفاده کنید.';
passwordHint.className = 'text-xs text-red-500 mt-1 text-right';
} else if (strength === 3) {
passwordHint.textContent = 'رمز عبور مناسب. می‌تواند قوی‌تر باشد.';
passwordHint.className = 'text-xs text-yellow-500 mt-1 text-right';
} else {
passwordHint.textContent = 'رمز عبور قوی!';
passwordHint.className = 'text-xs text-green-500 mt-1 text-right';
}
});
// Form validation
form.addEventListener('submit', function(e) {
e.preventDefault();
let isValid = true;
// Validate full name
const fullname = document.getElementById('fullname').value.trim();
if (fullname.length < 3) {
showError('fullname', 'لطفاً نام معتبر وارد کنید');
isValid = false;
}
// Validate email
const email = document.getElementById('email').value.trim();
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
showError('email', 'لطفاً ایمیل معتبر وارد کنید');
isValid = false;
}
// Validate phone number
const phone = phoneInput.value.trim();
if (!/^09\d{9}$/.test(phone)) {
showError('phone', 'لطفاً شماره تلفن معتبر وارد کنید (09xxxxxxxxx)');
isValid = false;
}
// Validate password
const password = passwordInput.value;
if (password.length < 8) {
showError('password', 'رمز عبور باید حداقل ۸ کاراکتر باشد');
isValid = false;
}
// Validate password match
const confirmPassword = confirmPasswordInput.value;
if (password !== confirmPassword) {
showError('confirmPassword', 'رمزهای عبور مطابقت ندارند');
isValid = false;
}
// Validate terms checkbox
if (!document.getElementById('terms').checked) {
alert('لطفاً با شرایط و ضوابط موافقت کنید');
isValid = false;
}
if (isValid) {
// Form is valid, you can submit data here
alert('ثبت نام با موفقیت انجام شد!');
form.reset();
// Reset strength bars
strengthBars.forEach(bar => {
bar.className = 'password-strength w-1/4 bg-gray-200 rounded-full';
});
passwordHint.textContent = 'حداقل ۸ کاراکتر با ترکیبی از حروف، اعداد و نمادها';
passwordHint.className = 'text-xs text-gray-500 mt-1 text-right';
}
});
function showError(fieldId, message) {
const field = document.getElementById(fieldId);
const errorDiv = document.createElement('div');
errorDiv.className = 'text-red-500 text-xs mt-1 text-right';
errorDiv.textContent = message;
// Remove existing error if any
const existingError = field.nextElementSibling;
if (existingError && existingError.className.includes('text-red-500')) {
existingError.remove();
}
field.classList.add('shake');
setTimeout(() => field.classList.remove('shake'), 500);
field.after(errorDiv);
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ali-ghadimi/test2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>