// ---------------------------------------------------------------------------------------- // isValidEmail // This function checks if a given email address is valid // Returns true or false // ---------------------------------------------------------------------------------------- qars_isValidEmail = function ( 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(String(email).toLowerCase()); } // ---------------------------------------------------------------------------------------- // isValidIdentityCard // This function checks if a given identityCard is valid // Returns true or false // ---------------------------------------------------------------------------------------- qars_isValidIdentityCard = function ( idCard ) { var validChars = 'TRWAGMYFPDXBNJZSQVHLCKET'; var nifRexp = /^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKET]$/i; var nieRexp = /^[XYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKET]$/i; var str = idCard.toString().toUpperCase(); if (!nifRexp.test(str) && !nieRexp.test(str)) return false; var nie = str .replace(/^[X]/, '0') .replace(/^[Y]/, '1') .replace(/^[Z]/, '2'); var letter = str.substr(-1); var charIndex = parseInt(nie.substr(0, 8)) % 23; if (validChars.charAt(charIndex) === letter) return true; return false; }