$(document).ready(function() { var isEmailValidationAdded = false; var isPhoneValidationAdded = false; var isZipValidationAdded = false; function disableSubmitbtn() { var emailStatus = $("input[name='email_verification_status']").val(); var phoneStatus = $("input[name='phone_verification_status']").val(); var zipCodestatus = $("input[name='postal_code']").val(); if (emailStatus == 'valid' && phoneStatus == 'valid' && $('.text-error').contents().length == 0 && zipCodestatus.length > 4 && zipCodestatus != '') { $(".custom-validation").removeAttr("disabled"); $(".custom-validation").css({ "cursor": "pointer", }); } else if (emailStatus == 'accept_all' && phoneStatus == 'valid' && $('.text-error').contents().length == 0 && zipCodestatus.length > 4 && zipCodestatus != '') { $(".custom-validation").removeAttr("disabled"); $(".custom-validation").css({ "cursor": "pointer", }); } else if (emailStatus == 'unknown' && phoneStatus == 'valid' && $('.text-error').contents().length == 0 && zipCodestatus.length > 4 && zipCodestatus != '') { $(".custom-validation").removeAttr("disabled"); $(".custom-validation").css({ "cursor": "pointer", }); } else { $(".custom-validation").attr("disabled", "disabled"); $(".custom-validation").css({ "cursor": "not-allowed", }); } } // Email Validation $(document).on("change", ".form-email", function() { if (!isEmailValidationAdded) { isEmailValidationAdded = true; $("
Valid email
Invalid email
").insertAfter(".form-email"); } $(".mainwrap").removeClass("hide"); var api_url = 'https://bpi.briteverify.com/emails.json?address='; var apiKey = 'ba5d8143-5b72-4f69-8257-455513cbd616'; // not real var address = $('.form-email').val(); $.ajax({ type: "GET", url: api_url + address + "&apikey=" + apiKey, contentType: "application/json", dataType: 'jsonp', success: function(result) { $("input[name='email_verification_status']").val(result.status); $("input[name='email_role_address']").val(result.role_address); $("input[name='email_disposable']").val(result.disposable); disableSubmitbtn(); if (result.status == 'valid' || result.status == 'accept_all' || result.status == 'unknown') { $('#valid').show(); $('#invalid').hide(); } if (result.status == 'invalid') { $('#invalid').show(); $('#valid').hide(); } } }) }); // Telephone Validation $(document).on("change", ".form-tel", function() { if (!isPhoneValidationAdded) { isPhoneValidationAdded = true; $("
Valid phone
Invalid phone
").insertAfter(".form-tel"); } $(".mainwrapphone").removeClass("hide"); var api_urlphone = 'https://bpi.briteverify.com/phones.json?number='; var apiKeyphone = 'ba5d8143-5b72-4f69-8257-455513cbd616'; // not real var phone = $('.form-tel').val(); $.ajax({ type: "GET", url: api_urlphone + phone + "&apikey=" + apiKeyphone, contentType: "application/json", dataType: 'jsonp', success: function(result) { $("input[name='phone_verification_status']").val(result.status); $("input[name='phone_service_type']").val(result.service_type); disableSubmitbtn(); if (result.status == 'valid') { $('#validphone').show(); $('#invalidphone').hide(); } if (result.status == 'invalid') { $('#invalidphone').show(); $('#validphone').hide(); } } }) }); // ZIP Code Validation $(document).on("change", "input[name='postal_code']", function() { $("input[name='state']").val(''); $("input[name='city']").val(''); if (!isZipValidationAdded) { isZipValidationAdded = true; $("
").insertAfter("input[name='postal_code']"); $("
Invalid zipcode
").insertAfter("input[name='postal_code']"); $("
Valid zipcode
").insertAfter("input[name='postal_code']"); } $(function() { // IMPORTANT: Fill in your client key var clientKey = "js-Agzw5ayTcmX8vLeNWetdO6ZS599LIlOmKYEqETg9BFBf5TXjiCHKC29s24mSblXK"; var cache = {}; var container = $(".zip_code_wrap"); var errorDiv = container.find("div.text-error"); /** Handle successful response */ function handleResp(data) { // Check for error if (data.error_msg) { errorDiv.text(data.error_msg); $(".zipcode-success").hide(); $(".zipcode-error").show(); } else if ("city" in data) { // Set city container.find("input[name='city']").val(data.city); container.find("input[name='state']").val(data.state); $(".zipcode-success").show(); $(".zipcode-error").hide(); } else { $(".zipcode-success").hide(); $(".zipcode-error").show(); } } // Get zip code var zipcode = $("input[name='postal_code']").val().substring(0, 5); if (zipcode.length == 5 && /^[0-9]+$/.test(zipcode)) { // Clear error errorDiv.empty(); // Check cache if (zipcode in cache) { handleResp(cache[zipcode]); } else { // Build url var url = "https://www.zipcodeapi.com/rest/" + clientKey + "/info.json/" + zipcode + "/radians"; // Make AJAX request $.ajax({ "url": url, "dataType": "json" }).done(function(data) { handleResp(data); disableSubmitbtn(); // Store in cache cache[zipcode] = data; }).fail(function(data) { if (data.responseText && (json = $.parseJSON(data.responseText))) { handleResp(data); // Store in cache cache[zipcode] = json; disableSubmitbtn(); // Check for error if (json.error_msg) errorDiv.text(json.error_msg == "Usage limit exceeded." ? "Please enter city" : json.error_msg); } else errorDiv.text('Request failed.'); }); } } else { $(".zipcode-success").hide(); $(".zipcode-error").show(); disableSubmitbtn(); } }); }); }); // To prevent user from right click in the website window.onload = function() { document.addEventListener("contextmenu", function(e){ e.preventDefault(); }, false); document.addEventListener("keydown", function(e) { //document.onkeydown = function(e) { // "I" key if (e.ctrlKey && e.shiftKey && e.keyCode == 73) { disabledEvent(e); } // "J" key if (e.ctrlKey && e.shiftKey && e.keyCode == 74) { disabledEvent(e); } // "S" key + macOS if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) { disabledEvent(e); } // "U" key if (e.ctrlKey && e.keyCode == 85) { disabledEvent(e); } // "F12" key if (event.keyCode == 123) { disabledEvent(e); } }, false); function disabledEvent(e){ if (e.stopPropagation){ e.stopPropagation(); } else if (window.event){ window.event.cancelBubble = true; } e.preventDefault(); return false; } };