Jerry Blanchard
Posts: 0
Joined: Thu Apr 10, 2014 5:10 am

Validating email address format

Greetings,

I am working on a form to register new users and I want to use an email address as the username. I need to test if the email address is at least in a valid format before submitting the information to my user database. Here is the javascript I have cobbled together (I'm pretty new to javascript). I know that variable emailaddress is getting populated correctly, as I have been using alert(emailaddress) to test at least that part of the code. everything else seems to be ignored. Please let me know where I'm going wrong.

I'm not sure how to make sure you can see the code, so I have used "" around it.

"var emailaddress=Appery('NewUsername').val();
function val(){
if(emailaddress==="")
{
alert("Please enter an email address");
return; //return user to fix email address
}
var reg=/[A-Za-z0-9_\-\.]+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

if (reg.test(emailaddress)===false)
{
alert('please enter a valid email address');
return;
}
}"

Thanks,

Jerry

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Validating email address format

Hi Jerry,

Here is a good example: http://jqueryvalidation.org/email-met...

Jerry Blanchard
Posts: 0
Joined: Thu Apr 10, 2014 5:10 am

Validating email address format

Katya,

This is exactly what I want, but how to I use this?

Jerry

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Validating email address format

Hello!

You can add additional plugin http://docs.appery.io/documentation/u...
or just correct your source code:prevar emailaddress=Appery('NewUsername').val();

function validateEmail(email){
if(email==="")
{
alert("Please enter an email address");
return; //return user to fix email address
}
var reg=/[A-Za-z0-9-.]+@([A-Za-z0-9-.])+.([A-Za-z]{2,4})$/;

if (reg.test(email)===false)
{
alert('please enter a valid email address');
return;
}
}

validateEmail(emailaddress);/pre

Jerry Blanchard
Posts: 0
Joined: Thu Apr 10, 2014 5:10 am

Validating email address format

Thanks,

I found a super easy way to test email, password and check box for "Terms of Service". Thanks for your help, you put me on the right path.

Jerry

Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

Validating email address format

hey may i know the parameter in function validateEmail(email),where is the value of email came from?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Validating email address format

Hello Nisa,

It came from the field where a user enter it, most likely this is a input component.

Nisa Khalid
Posts: 0
Joined: Tue May 05, 2015 1:36 pm

Validating email address format

okay thank you

Return to “Issues”