$(document).ready(function () { window['validationEnterInsolationByZipCode.checkZipCode'] = function (element) { // init var validationMessage = ''; // action var zipCode = element.val(); if (zipCode != '') { $.ajax({ async: false, url: 'plugin/top50solar/common/enterInsolationByZipCode/ajax?key=' + getUrlParameter('key'), context: element, headers: { 'Accept': 'application/json' }, method: 'POST', data: { method: 'isZipCodeValid', zipCode: zipCode } }).done(function (data) { if (data !== 'empty') { validationMessage = data; } window.validationCallback(element, validationMessage); }); } // return return validationMessage; }; window.getUrlParameter = function getUrlParameter(sParam) { var sPageURL = decodeURIComponent(window.location.search.substring(1)), sURLVariables = sPageURL.split('&'), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split('='); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : sParameterName[1]; } } }; });