Page 1 of 1

Validating email address format

Posted: Wed Apr 23, 2014 8:28 pm
by Jerry Blanchard

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


Validating email address format

Posted: Wed Apr 23, 2014 8:58 pm
by Kateryna Grynko

Hi Jerry,

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


Validating email address format

Posted: Wed Apr 23, 2014 10:03 pm
by Jerry Blanchard

Katya,

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

Jerry


Validating email address format

Posted: Thu Apr 24, 2014 9:24 am
by Maryna Brodina

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


Validating email address format

Posted: Thu Apr 24, 2014 10:56 pm
by Jerry Blanchard

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


Validating email address format

Posted: Thu May 14, 2015 4:51 am
by Nisa Khalid

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


Validating email address format

Posted: Thu May 14, 2015 6:00 pm
by Evgene Karachevtsev

Hello Nisa,

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


Validating email address format

Posted: Thu May 14, 2015 6:14 pm
by Nisa Khalid

okay thank you