$('#error').hide(1000);

console.log();

email_address = false;
password1 = false;
user_name = false;
full_name = false;
gender = false;
state = false;
agree = false;
dob = false;
country = false;

$('#email_address').keyup(function() {
check_email();
});
$('#password1').keyup(function() {
check_password();
});
$('#user_name').keyup(function() {
check_username();
});
$('#full_name').keyup(function() {
check_fullname();
});
$('#gender').keyup(function() {
check_gender();
});
$('#state').keyup(function() {
check_state();
});
$('#agree').keyup(function() {
check_box();
});
$('#dob').keyup(function() {
check_dob();
});
$('#country').keyup(function() {
check_country();
});
function check_email() {
var email = $('#email_address').val();
var indexat = email.indexOf("@");
var indexdot = email.indexOf(".");

if(indexat < 1 || (indexdot-indexat) < 2)
{
$('#error1').html('Email is invalid');
$('#error1').css ('color', '#d90000');
$('#email_address').css ('border', '2px solid #d90000');
$('#error1').show(1000);
}else{
$('#email_address').css('border','2px solid #34F458');
$('#error1').hide(1000);
email_address = true;
}
}
function check_password()
{
var password_len = $('#password1').val().length;
if (password_len <= 8) {
$('#error7').html('Password must be at leat 8 characters');
$('#password1').css('border','2px solid #F90A0A');
$('#error7').css('color', 'red');	
$('#error7').show(1000);

}else{
$('#password1').css('border','2px solid #34F458');
$('#error7').hide(1000);
error_pass = true;
}
}
 

 

function check_fullname()
{
var pattern = /^[a-z A-Z]+$/;
var Profession = $('#full_name').val();
if (pattern.test(Profession) && Profession !== '') {
$('#error').hide(1000);
$('#full_name').css('border', '2px solid red');
}else{
$('#error').html('full name contain uppercase & lowercase letters');
$('#full_name').css('border','2px solid lightgreen');
$('#error').css('color', 'red');
$('#error').show(1000);
full_name = true;
}
}

function check_username()
{
var pattern = /^[a-z A-Z 0-9]+$/;
var Profess = $('#user_name').val();
if (pattern.test(Profess) && Profess !== '') {
$('#error4').hide(1000);
$('#user_name').css('border', '2px solid #34F458');
}else{
$('#error4').html('username must contain uppercase , lowercase & numbers');
$('#user_name').css('border','2px solid #F90A0A');
$('#error4').css('color', 'red');
$('#error4').show(1000);
user_name = true;
}
}


function check_gender()
{

var post_addr = $('#gender').val();
if (post_addr !== '') {
$('#error6').hide(1000);
$('#gender').css('border', '2px solid #34F458');
}else{
$('#error6').html('Post Address cannot be empty');
$('#gender').css('border','2px solid #F90A0A');
$('#error6').css('color', 'red');
$('#error6').show(1000);
gender = true;
}
}

function check_state()
{

var post_code = $('#state').val();
if (post_code !== '') {
$('#error3').hide(1000);
$('#state').css('border', '2px solid #34F458');
}else{
$('#error3').html('state cannot be empty');
$('#state').css('border','2px solid #F90A0A');
$('#error3').css('color', 'red');
$('#error3').show(1000);
state = true;
}
}
function check_box()
{
var pattern = /^[0-9]+$/;
var phone_num = $('#agree').val();
if (pattern.test(phone_num) && phone_num !== '') {
$('#error8').hide(1000);
$('#agree').css('border', '2px solid #34F458');
}else{
$('#error8').html('click the checkbox');
$('#agree').css('border','2px solid #F90A0A');
$('#error8').css('color', 'red');
$('#error8').show(1000);
full_name = true;
}
}
function check_dob()
{
var dob = $('#dob').val();
if (dob !== '') {
$('#error5').hide(1000);
$('#dob').css('border', '2px solid #34F458');
}else{
$('#error5').html('date of birth must be in this format 01-01-1990');
$('#dob').css('border','2px solid #F90A0A');
$('#error5').css('color', 'red');
$('#error5').show(1000);
agree = true;
}
}

function check_country()
{

var pattern = /^[a-z A-Z]+$/;
var country = $('#country').val();
if (pattern.test(country) && country !== '') {
$('#error2').hide(1000);
$(country).css('border', '2px solid #34F458');
}else{
$('#error2').html('Country cannot be empty');
$(country).css('border','2px solid #F90A0A');
$('#error2').css('color', 'red');
$('#error2').show(1000);
dob = true;
}
}

$('#register').click(function() {

email_address = false;
error_pass = false;
error_fname = false;
error_lname = false;
user_name = false;
country = false;
gender = false;
state = false;
full_name = false;
agree = false;
dob = false;

check_email();
check_password()
check_username();
check_fullname();
check_gender();
check_state();
check_box();
check_dob();
check_country();

if (email_address  === false && password1 === false && 
user_name === false && full_name === false &&
gender === false && state === false && 
agree === false && dob === false && country === false) {

$('#submit_1').html("Please wait..");
$('#submit_1').addClass('btn-success');

}else{
return false;
}
});