Android Question Check for for valid email and characters

Makumbi

Well-Known Member
Licensed User
B4X:
If CCode.Text = "" Or Phone.Text = "" or  Email.Text = ""  Then
        Msgbox("You Must enter Country Code and Your Phone Number","Missed data field")
        Return

How can i check for Valid Email for the Email field and also Check the Phone Filed to make sure its characters are not Less or greater than 10 characters before inserting them into the table Please help
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Sandman

Expert
Licensed User
Longtime User

I see this mentioned now and then, and it's a bit unfortunate that the page doesn't mention the limitations of the code snippet as it produces somewhat incorrect results. (Well, both do, as they use the same regex.) It's simple to test, just go to the Wikipedia page for email addresses and test the valid and invalid ones: https://en.wikipedia.org/wiki/Email_address#Examples. Yes, some of them are very strange, but that doesn't make them less valid, or invalid. I ran them through an online regex tool and got the result below. (For more strange examples, search the net. Here's a list I found right away.)

upload_2018-11-21_21-12-12.png



I am fully aware that the snippet is absolutely fine for 99% of the cases, but I think it should be clarified that it's not 100% correct. I have no problem with anyone using it, as long as they understand this.

In reality there is only one way to validate an email address with 100% certainty: Send a test email to the entered address, with a link for the user to click.


How can i check for Valid Email ... to make sure its characters are not Less or greater than 10 characters

A valid address can be as short as 3 characters, as far as I can tell. Odds are against that you will ever encounter such an address obviously, but just picking 10 as a limit is just plain wrong. I'm sure that [email protected] would agree with me.
 
Upvote 0
Top