diff --git a/app.py b/app.py index 94faec4..b198245 100644 --- a/app.py +++ b/app.py @@ -12,6 +12,7 @@ import streamlit.components.v1 as components import os from dotenv import load_dotenv +import re #AI Integration import anthropic import datetime @@ -148,6 +149,12 @@ def load_lottie_url(url: str): return response.json() return None +# Email Validation Function +def is_valid_email(email): + # Updated pattern requires text before and after @ and . + pattern = r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$" + return re.match(pattern, email) is not None + # Main function to control page navigation def main(): selected = option_menu( @@ -819,8 +826,12 @@ def show_about_and_feedback(): st.write("Stay updated with our latest features, activities, and wellness tips.") email = st.text_input("Enter your email address:") if st.button("Subscribe"): - if email: + if is_valid_email(email): st.success("Thank you for subscribing! You'll receive updates and tips directly to your inbox.") + else: + st.error("Please enter a valid email address with a format like 'example@domain.com'.") + + st.write("---") st.markdown('
© 2024 SereniFi. All rights reserved.
', unsafe_allow_html=True)