Middle
The best app in the world Registration Age Full Name Email Phone Number Password Date of Birth Requirements Age - Slider with cutoffs at 30 and 60 - Discount depends on selected value: Up to 30 - 5% up to 60 - 10% after 60 - 22% Full Name - Cyrillic, - space separating parts of the full name Email - @ mask Phone Number - +7 Password - Latin letters - No more than 8 characters - Contains at least 3 uppercase letters - Ninth character - special symbol Date of Birth - Format dd.mm.yyyy
sobes.tech AI
Answer from AI
To implement registration with the specified requirements, validation can be used on both the frontend and backend.
Age:
- Use a slider with marks at 30 and 60.
- Calculate the discount based on the selected value:
- Up to 30 years — 5%
- Up to 60 years — 10%
- Over 60 — 22%
Full Name:
- Check that the input text is in Cyrillic.
- Name parts are separated by a space.
- Regular expression for validation:
/^[А-ЯЁ][а-яё]+(\s[А-ЯЁ][а-яё]+){1,2}$/
Email:
- Check for the presence of
@symbol and basic email structure. - Example regex:
/^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,}$/
Phone Number:
- Check that the number starts with
+7. - Example:
/^\+7\d{10}$/
Password:
- Latin characters, no more than 8 characters.
- At least 3 uppercase letters.
- The ninth character is a special symbol (if length >= 9).
- Validation example:
import re
password = "AbCDefGh!"
if len(password) <= 8:
print("Password is too short")
else:
uppercase_count = len(re.findall(r'[A-Z]', password))
if uppercase_count < 3:
print("Less than 3 uppercase letters")
if len(password) >= 9 and not re.match(r'.{8}[!@#$%^&*]', password):
print("Ninth character is not a special symbol")
Date of Birth:
- Format
dd.mm.yyyy. - Validation with regex:
/^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[0-2])\.\d{4}$/
This approach ensures correct data input and allows dynamic calculation of age-based discounts.