function validateEmail($email) {
var emailReg = /^([w-.]+@([w-]+.)+[w-]{2,4})?$/;
return emailReg.test( $email );
}
if( !validateEmail(emailaddress)) { /* do stuff here */ }
function validateEmail(email)
{
var re = /^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validatePhone(phone)
{
// 880-1710-336617
var re = /^(?(d{3}))?[- ]?(d{4})[- ]?(d{6})$/;
return re.test(phone);
}
$('#button').click(function(){
field = $('#email').val();
//If not an email AND not a phone
if(validateEmail(field))
{
alert('Email Passed');
//show_error_msg('error_signup_email','Enter a valid email address or a phone number');
//jQuery("#signup_email").focus();
return true;
} else if (validatePhone(field)){
alert('Phone Passed');
return true;
}
else alert('Email or Phone Error');
});
function validateEmail(email) {
var re =
/^(([^<>()[].,;:s@"]+(.[^<>()[].,;:s@"]+)*)|(".+"))@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}])|(([a-zA-Z-0-9]+.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validatePhone(phone) {
// 880-1710-336617 or 8801710336617
var re = /^(?:(?:+|00)88|01)?d{11}$/;
return re.test(phone);
}
function validate() {
document.getElementById('email_error').innerHTML = "";
field = $('#email_phone').val();
//If not an email AND not a phone
if (validateEmail(field)) {
//alert('Email Passed');
//onChange();
document.getElementById('email').value = document.getElementById('email_phone').value;
document.getElementById('phone').value = "";
//return true;
} else if (validatePhone(field)) {
//alert('Phone Passed');
document.getElementById('phone').value = document.getElementById('email_phone').value;
document.getElementById('email').value = "";
//return true;
} else {
//alert('Email or Phone Error');
document.getElementById('email').value = "";
document.getElementById('phone').value = "";
let text;
text = "<strong><span style='color:red'> Email or Phone number Invalid</span></strong>";
document.getElementById("email_error").innerHTML = text;
return false;
}
// Password Match
var password = document.getElementById('password').value;
var confirm_password = document.getElementById('password_confirm').value;
document.getElementById("password_error").innerHTML="";
if(password==""){
document.getElementById("password_error").innerHTML="Please enter password";
return false;
}
if (password != confirm_password) {
let text1;
text1 ="<strong><span style='color:red'>The password and its confirm are not the same </span></strong>";
document.getElementById("password_match").innerHTML = text1;
return false;
}
// Clear Email field value if change
$("#email_phone").change(function() {
document.getElementById('email').value = "";
});
// Clear Phone field value if change
$("#email_phone").change(function() {
document.getElementById('phone').value = "";
});
$("#email_phone").change(function() {
document.getElementById('password_error').value = "";
});
}