
function checkMail() {
 var x = document.forms[0].email.value;
 var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
 if (filter.test(x)) {
  document.getElementById('email-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
  return true;
 }
 else {
  document.getElementById('email-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  return false;
 }
}

function checkAndSubmit() {

 if(document.forms[0].pseudo.value == '') {
  document.getElementById('pseudo-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Nickname must be filled !");
  return(false);
 }

 if (document.forms[0].pseudo.value.length < 3) {
  document.getElementById('pseudo-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Nickname must have a size of at least 3 characters !");
  document.forms[0].pseudo.focus();
  return(false);
 }

 var checkStr = document.forms[0].pseudo.value;
 if (/\W/.test(checkStr)) {
  document.getElementById('pseudo-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Nickname must contain only alphanumeric characters !");
  document.forms[0].pseudo.focus();
  return(false);
 }

 document.getElementById('pseudo-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";

 if( !checkMail() ) {
  alert("Invalid EMail address !");
  document.forms[0].email.focus();
  return(false);
 }


 if(document.forms[0].passwd.value.length < 6) {
  document.getElementById('passwd-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Password must have a size of at least 6 characters !");
  document.forms[0].passwd.focus();
  return(false);
 }

 if(document.forms[0].passwd.value != document.forms[0].passwd2.value) {
  document.getElementById('passwd2-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Passwords do not match !");
  document.forms[0].passwd2.focus();
  return(false);
 }

 document.getElementById('passwd-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
 document.getElementById('passwd2-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";

 if(document.forms[0].age.value == '') {
  document.getElementById('age-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
 }
 else {
  if(isNaN(document.forms[0].age.value)) {
    document.getElementById('age-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
    alert("Age must be numeric !");
    document.forms[0].age.focus();
    return(false);
  }
  else {
   document.getElementById('age-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
  }
 }

 document.subsForm.submit();
 return true;
}

function checkAndSubmitProfile() {
 if( !checkMail() ) {
  alert("Invalid EMail address !");
  document.forms[0].email.focus();
  return(false);
 }


 if(document.forms[0].passwd.value.length < 6) {
  document.getElementById('passwd-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Password must have a size of at least 6 characters !");
  document.forms[0].passwd.focus();
  return(false);
 }

 if(document.forms[0].passwd.value != document.forms[0].passwd2.value) {
  document.getElementById('passwd2-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
  alert("Passwords do not match !");
  document.forms[0].passwd2.focus();
  return(false);
 }

 document.getElementById('passwd-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
 document.getElementById('passwd2-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";

 if(document.forms[0].age.value == '') {
  document.getElementById('age-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
 }
 else {
  if(isNaN(document.forms[0].age.value)) {
    document.getElementById('age-stat').src = "http://www.rylax.be/D-Chat/Icons/no.png";
    alert("Age must be numeric !");
    document.forms[0].age.focus();
    return(false);
  }
  else {
   document.getElementById('age-stat').src = "http://www.rylax.be/D-Chat/Icons/yes.png";
  }
 }

 document.subsForm.submit();
 return true;
}


