Spaces:
Sleeping
Sleeping
Update templates/signup.html
Browse files- templates/signup.html +35 -0
templates/signup.html
CHANGED
@@ -136,6 +136,41 @@
|
|
136 |
})
|
137 |
.catch(error => console.error('Error:', error));
|
138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
</script>
|
140 |
|
141 |
</body>
|
|
|
136 |
})
|
137 |
.catch(error => console.error('Error:', error));
|
138 |
}
|
139 |
+
|
140 |
+
|
141 |
+
function validateForm(event) {
|
142 |
+
const referralCode = document.getElementById('referral').value.trim();
|
143 |
+
|
144 |
+
if (referralCode && referralCode.length !== 8) {
|
145 |
+
const errorMessage = document.getElementById('error-message');
|
146 |
+
errorMessage.textContent = 'Referral code must be 8 characters long.';
|
147 |
+
event.preventDefault();
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
|
153 |
+
function checkReferralCode() {
|
154 |
+
const referralCode = document.getElementById('referral').value.trim();
|
155 |
+
|
156 |
+
if (referralCode) {
|
157 |
+
fetch('/check_referral', {
|
158 |
+
method: 'POST',
|
159 |
+
headers: { 'Content-Type': 'application/json' },
|
160 |
+
body: JSON.stringify({ referral_code: referralCode })
|
161 |
+
})
|
162 |
+
.then(response => response.json())
|
163 |
+
.then(data => {
|
164 |
+
const errorMessage = document.getElementById('error-message');
|
165 |
+
if (!data.valid) {
|
166 |
+
errorMessage.textContent = 'Invalid referral code.';
|
167 |
+
} else {
|
168 |
+
errorMessage.textContent = '';
|
169 |
+
}
|
170 |
+
})
|
171 |
+
.catch(error => console.error('Error:', error));
|
172 |
+
}
|
173 |
+
}
|
174 |
</script>
|
175 |
|
176 |
</body>
|