﻿//login.aspx
  function checkLoginForm() {
      var account = $('#ctl00_cphContent_txtAccount').get(0);
      if (account.value.trim().length == 0) {
        alert('Please enter the account.');
        return false;
      }
      
      var pwd = $('#ctl00_cphContent_txtPwd').get(0);
      if (pwd.value.trim().length == 0) {
        alert('Please enter the password.');
        return false;
      }
      
      return true;
  }
  
  function checkRegForm() {
      var account = $('#ctl00_cphContent_txtName').get(0);
      if (account.value.trim().length == 0) {
        alert('Please enter the name.');
        return false;
      }
      
      var company = $('#ctl00_cphContent_txtCompany').get(0);
      if (company.value.trim().length == 0) {
        alert('Please enter the company.');
        return false;
      }
      
      var address = $('#ctl00_cphContent_txtAddress').get(0);
      if (address.value.trim().length == 0) {
        alert('Please enter the address.');
        return false;
      }
         
      var email = $('#ctl00_cphContent_txtEmail').get(0);
      if (email) {
        if (email.value.length > 0 && !email.value.isEmail()) {
        alert('Please enter the correct email format.');
        return false;
        }
        if (email.value.trim().length == 0) {
        alert('Please enter the email.');
        return false;
        }
      }
        
      var phone = $('#ctl00_cphContent_txtPhone').get(0);
      if (phone) {
          if (phone.value.trim().length == 0) {
            alert('Please enter the phone number.');
            return false;
          }
          if (phone.value.length > 0 && !phone.value.isPhone()) {
            alert('Please enter the the correct phone number.');
            return false;
          }
      }
      
      return true;
  }
  
  //myaccount.aspx
  
  function checkUpdateForm() {
      var account = $('#ctl00_cphContent_txtAccount').get(0);
      if (account.value.trim().length == 0) {
        alert('Please enter the name.');
        return false;
      }
      
      var company = $('#ctl00_cphContent_txtCompany').get(0);
      if (company.value.trim().length == 0) {
        alert('Please enter the company.');
        return false;
      }
      
      var address = $('#ctl00_cphContent_txtAddress').get(0);
      if (address.value.trim().length == 0) {
        alert('Please enter the address.');
        return false;
      }
         
      var email = $('#ctl00_cphContent_txtEmail').get(0);
      if (email) {
        if (email.value.length > 0 && !email.value.isEmail()) {
        alert('Please enter the correct email format.');
        return false;
        }
        if (email.value.trim().length == 0) {
        alert('Please enter the email.');
        return false;
        }
      }
        
      var phone = $('#ctl00_cphContent_txtPhone').get(0);
      if (phone) {
      if (phone.value.trim().length == 0) {
        alert('Please enter the phone number.');
        return false;
      }
      if (phone.value.length > 0 && !phone.value.isPhone()) {
        alert('Please enter the the correct phone.');
        return false;
      }
      }
      
      return true;
  }
  
  function checkChangePwdForm() {
      var oldPwd = $('#ctl00_cphContent_txtOldPwd').get(0);
      if (oldPwd.value.length == 0) {
        alert('Please enter the old password.');
        return false;
      }
      
      var newPwd = $('#ctl00_cphContent_txtNewPwd').get(0);
      if (newPwd.value.length == 0) {
        alert('Please enter the new password.');
        return false;
      }
      
      var re = /^.{6,}$/;
      if (!re.test(newPwd.value)) {
        alert('Password length can not be less than 6.');
        return false;
      }
      
      var newPwdAgain = $('#ctl00_cphContent_txtNewPwdAgain').get(0);
      if (newPwdAgain.value != newPwd.value) {
        alert('Enter your password twice inconsistent.');
        return false;
      }
      
      return true;
      }
      
   function checkForgetPasswordForm() {
      var email = $('#ctl00_cphContent_txtAccountRecovery').get(0);
      if (email) {
        if (email.value.length > 0 && !email.value.isEmail()) {
            alert('Please enter the correct email format.');
            return false;
        }
        if (email.value.trim().length == 0) {
            alert('Please enter the email.');
            return false;
        }
      }
      return true;
      
   }