Page 1 of 1

Valid email address code not working.

Posted: Tue Jul 07, 2015 3:04 pm
by Shaun Summers

Hi,

I've used the code from tutorial https://devcenter.appery.io/tutorials... to validate the registration fields. It all works fine except for checking that the email address is a valid email format.

if ($.trim(Appery("loginInput").val()) !== "") {
if (Appery("passwordInput").val() == Appery("confirmPasswordInput").val()) {
if ($.trim(Appery("emailInput").val()) !== "") {
if (!document.getElementsByName("emailInput")[0].checkValidity || document.getElementsByName("emailInput")[0].checkValidity()) {register.execute({});
} else {
alert("Please enter a valid email");
}
} else {
alert("Please specify your email");
}
} else {
alert("Passwords don't match!");
}
} else {
alert("Please enter your login");
}

_________________

Any ideas on where I've gone wrong. I've doubled checked it against the original and all my field names are correct.

Regards, Shaun.


Valid email address code not working.

Posted: Tue Jul 07, 2015 4:38 pm
by Evgene Karachevtsev

Hello Shaun,

Please try this code to validate email while we're testing the one from the tutorial
precodefunction validateEmail(email) {
var re = /^([\w-]+(?:\.[\w-]+))@((?:[\w-]+\.)\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}/code/pre


Valid email address code not working.

Posted: Wed Jul 08, 2015 9:41 am
by Shaun Summers

Thanks for the answer. I'm afraid I don't really understand where to include the code that you've given me in the original code that I posted (I've just been following the tutorial...)

Shaun.


Valid email address code not working.

Posted: Wed Jul 08, 2015 10:49 am
by Shaun Summers

I got another work around to work. I've posted it here in case it is useful for somebody else:

if ($.trim(Appery("Country_Select").val()) !== "Not_selected") {
if ($.trim(Appery("loginInput").val()) !== "") {
if (Appery("passwordInput").val() == Appery("confirmPasswordInput").val()) {
if ($.trim(Appery("emailInput").val()) !== "") {
if( /(.+)@(.+){2,}\.(.+){2,}/.test((Appery("emailInput").val()))) {register.execute({});
} else {
alert("Please enter a valid email");
}
} else {
alert("Please specify your email");
}
} else {
alert("Passwords don't match!");
}
} else {
alert("Please enter your login");
}
} else {
alert("Please enter your country");
}

Regards, Shaun


Valid email address code not working.

Posted: Fri Aug 14, 2015 8:52 pm
by Gurinder Mann

function validateEmail(email)
{
var re = /^([\w-]+(?:\.[\w-]+))@((?:[\w-]+\.)\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return re.test(email);
}
var email = Apperyio('txt_mobiletextinput_4').val();

var errorMsg = "";

if ($.trim(email) === "")
{
errorMsg = errorMsg + "Email cannot be blank \n";
}

if (errorMsg === "")
{
restservice2.execute({});
}
else
{
alert("Please fix the following error: \n" + errorMsg);
}

---------------------------------------------------------------------------------------------------------

This is the code I am using I want to validate the email and display a error message if the email is not valid. how do I fix the code to do that??