(function($) { if (typeof $$epiforms !== 'undefined') { var $fallBackFrom = $(".fallbackfrom"); var $fallBackTo = $(".fallbackto"); var defaultReferer = "securitas.com"; $.extend(true, epi.EPiServer.Forms, { /// extend the Validator to validate Visitor's value in Clientside. Validators: { "SecuritasWebNew.Models.Elements.FriendlyCaptchaValidator": function () { return {}; } }, }) $$epiforms(document).ready(function myfunction() { // listen to event when form is about submitting $$epiforms(".EPiServerForms").on("formsStepValidating", function(data) { var hostname = window.location.hostname; var finalHost = hostname.includes("localhost") ? defaultReferer : hostname; // console.log($fallBackTo.val()); if(($fallBackFrom.val() !== null && $fallBackFrom.val() !== "")){ if (($fallBackTo.val() === "" || $fallBackTo.val() === null)) { $fallBackTo.val($fallBackFrom.val()+ "@" + finalHost); console.log($fallBackTo.val()); } } }); }); } })($$epiforms || $);