How to validate if entered email is in valid format.




An email must have @ and . in the email address name, so a check needs to be perform to check if data entered by user is a valid format of email id or not.

below code will to design the above form, then we will check by entering data differently to validate entered data in email section.


#program

try:
from Tkinter import *
except:
from tkinter import *

def display(message):
mb = Tk()
mb.geometry('200x50+250+75')
mb.title("Aeties_Action")
msg = Label(mb, text=message).pack()
mainloop()

def validate_email():
email=email_e.get()
if '@' in email and '.' in email:
display("e-mail format is valid")
else:
display("invalid format of e-mail")

mw = Tk()

mw.geometry("400x100+50+50")
mw.title("AETies : Automation Expert Technologies")

email_l = Label(mw, text=' enter email id :', pady=5).pack()
email_e = Entry(mw, width=20)
email_e.pack()
email_btn = Button(mw, text=' Validate ', command=validate_email).pack()

mainloop()


below are the different cases for user input of e-mail id.







Format of mail can be validated, but not if email is a valid mail id or not. 





Comments

My photo
Techno Xpresss
Bangalore, Karnataka, India