var eVisa = eVisa || {}; var $app = { context: "" }; eVisa.ForgotPassword = { init: function () { $app.context = this; this.sendPassword(); this.createRequestObj(); }, createRequestObj: function () { var obj = {}; obj.Email_Id = $('#emailId').val(); obj.CaptchaCode = $('#CaptchaCode').val(); return obj; }, sendPassword: function () { $("#btnSendPassword").click(function (e) { e.preventDefault(); $('#divOtpSuccessMsg').html(''); $('#divOtpSuccessMsg').hide(); $('#divOtpFailureMsg').html(''); $('#divOtpFailureMsg').hide(); if ($('#formForgetPassword').valid()) { var requestObj = $app.context.createRequestObj(); $('#divOverlay').show(); if (!captchaManager.IsCaptchaValid(captchaObj)) return; ajaxindicatorstart(); $.ajax({ url: siteRoot + "Registration/ForgotPassword", type: "POST", data: { viewModel: requestObj, //emailId: $('#emailId').val(), __RequestVerificationToken: $('input[name="__RequestVerificationToken"]').val() }, success: function (data) { $('#divOverlay').hide(); ajaxindicatorstop(); if (data.success) { $('#divOtpSuccessMsg').html(data.message); $('#divOtpSuccessMsg').show(); $('#spnCaptchaCode').hide() setTimeout(function () { window.location.href = siteRoot + 'Login'; }, 2000); } else { $('#divOtpFailureMsg').html(data.message); $('#divOtpFailureMsg').show(); $('#CaptchaCode').val(''); refreshCaptcha(); $('html, body').animate({ scrollTop: $("#divOtpFailureMsg").offset().top }, 500); } }, error: function (a, b, c) { $('#divOverlay').hide(); refreshCaptcha(); console.log(a); console.log(b); console.log(c); ajaxindicatorstop(); } }); } }); } }