Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email Validation on Subscription Button #129 #170

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 '[email protected]'.")



st.write("---")
st.markdown('<p style="text-align: center;">© 2024 SereniFi. All rights reserved.</p>', unsafe_allow_html=True)
Expand Down