Email Textbox Validation [SOLVED]

Get help using Construct 2

Post » Sat Jun 02, 2012 11:23 am

Hi Guys,

Once a person has entered his/her email address in a textbox, how do I validate that it's in a proper email format, e.g. eye@eye.com?

The manual says that I can set the textbox type to 'email':
http://www.scirra.com/manual/117/textbox

But how do I validate it, and if it's non-email format, then how do I return an error?

EDIT June 4, 2012 - I've figured it out.

You can use the system expression - tokencount.

From the manual:
"tokencount(src, separator)
Count how many tokens occur in src using separator. For example, tokencount("apples|oranges|bananas", "|") returns 3."

I did tokencount("bob@bob.com", "@") to check for the number of @'s (there should only be one).

Then did the same for "."'s.

Regular expressions would have been better, but this kind of works.

EyeHawk2012-06-03 14:15:34
B
34
S
8
G
3
Posts: 328
Reputation: 7,692

Post » Tue Apr 30, 2013 7:47 am

can you upload any sample capx file for validation email?
B
7
S
2
G
3
Posts: 13
Reputation: 2,266

Post » Sat Apr 18, 2015 3:32 pm

Thanks for the tip about tokencount('string','token'). One oddity I've noticed is that for some reason I'm having to set the result to -1 in order to get an accurate count. Weird, but it works.
B
9
S
1
Posts: 33
Reputation: 612


Return to How do I....?

Who is online

Users browsing this forum: Braus, MatheusCastellar, shinkan and 26 guests