var Unibase; (function (Unibase) { let Forms; (function (Forms) { let Controls; (function (Controls) { class PhoneNumber { init(formpropertyid, prop, callback) { this.docpropertyname = prop.DocPropertyName; var instance = PhoneNumber.Instance(); var container = "control-container-" + formpropertyid; instance.loadControlSettings(prop.ControlJsonText, prop.FormPropertyId); instance.loadPropertySettings(prop.PropertySettings, prop.FormPropertyId); this.formname = prop.DocPropertyName; var formid = $("#txtPhn_" + prop.DocPropertyName).parents('.formValidate').attr('id'); var errormsg = $("#" + formid).find('.bizgaze_FormErrorMessages').attr('id'); $(".creditnumber").keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { return false; } }); $(".dropdown_phonetype").change(function () { var InstalledAppId = Unibase.Themes.Providers.DetailHelper.installedAppId; var phonetype = $(".dropdown_phonetype").val(); if (phonetype === "2") { if ($("#a_Verify_phonenumber").hasClass("otp_verified")) { $("#a_Verify_phonenumber").removeClass("otp_verified"); $("#a_Verify_phonenumber").text(''); $("#a_Verify_phonenumber").removeAttr("style"); } } }); $("#a_Verify_" + prop.DocPropertyName).click(function () { if ($("#a_Verify_" + prop.DocPropertyName).hasClass("otp_verified") == false) { var attribute = $(this); var ContactNumber = $("#txtPhn_" + prop.DocPropertyName).val().toString(); if (ContactNumber == "" || ContactNumber == undefined) { MessageHelper.Instance().showError("Please Enter Mobile Number for Verification", "" + errormsg); return false; } Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile('platform/controls/phonenumber/managers/phonenumbermanager.js', function () { Unibase.Platform.Controls.Phonenumber.Managers.PhonenumberManager.Instance().getVerified(ContactNumber).then(function (response) { if (response.errors != null) { MessageHelper.Instance().showError("Mobile Number Is Already Exist", "" + errormsg); return false; } else { if (ContactNumber.length > 9) { $("#a_Verify_" + prop.DocPropertyName).text('Re-send').css('color', 'green'); Unibase.Forms.Controls.PhoneNumber.Instance().SendOtp(ContactNumber, prop.DocPropertyName); $(".div_Otp_" + prop.DocPropertyName).removeClass("hidden"); $("#btn_submit_" + prop.DocPropertyName).addClass("hidden"); $("#txtOtp_" + prop.DocPropertyName).val(''); $("#txtOtp_" + prop.DocPropertyName).addClass("required"); } else { MessageHelper.Instance().showError("Mobile Number should be 10 digits", "" + errormsg); } } }); }); } }); $("#txtPhn_" + prop.DocPropertyName).keyup(function () { $("#a_Verify_" + prop.DocPropertyName).text('Verify').css('color', 'green'); $("#txtOtp_" + prop.DocPropertyName).val(''); $("#txtOtp_" + prop.DocPropertyName).removeClass("required"); $(".div_Otp_" + prop.DocPropertyName).addClass("hidden"); $("#txtOtp_" + prop.DocPropertyName).removeClass("required"); }); $("#txtPhn_" + prop.DocPropertyName).on("input", function () { const inputVal = $(this).val(); $(this).val(inputVal.replace(/\D/g, '')); }); $("#txtOtp_" + prop.DocPropertyName).removeClass('required'); $("#btn_submit_" + prop.DocPropertyName).click(function () { var Otp = $("#txtOtp_" + prop.DocPropertyName).val().toString(); if (Otp.length == 6) { Unibase.Forms.Controls.PhoneNumber.Instance().SubmitOTP(prop.DocPropertyName); } else { MessageHelper.Instance().showError("Please Enter Valid OTP", "" + errormsg); $("#txtOtp_" + prop.DocPropertyName).addClass('form-group-required'); } }); $("#txtOtp_" + prop.DocPropertyName).attr('maxlength', '6'); $("#txtOtp_" + prop.DocPropertyName).keypress(function (e) { if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) { MessageHelper.Instance().showError("Numbers Only Allowed", '' + errormsg); return false; } else { if ($("#txtOtp_" + prop.DocPropertyName).val().toString().length >= 5) { $("#btn_submit_" + prop.DocPropertyName).removeClass('hidden'); } else { $("#btn_submit_" + prop.DocPropertyName).addClass('hidden'); } } }); $("input#txtOtp_" + prop.DocPropertyName).unbind("keypress change input paste").bind("keypress change input paste", function () { var value = $("#txtOtp_" + prop.DocPropertyName).val().toString(); if (value != "") { var IsNumeric = $.isNumeric(value); if (IsNumeric && value.length >= 5) { $("#btn_submit_" + prop.DocPropertyName).removeClass('hidden'); } else if (IsNumeric == false) { $("#btn_submit_" + prop.DocPropertyName).addClass('hidden'); $("#txtOtp_" + prop.DocPropertyName).val(""); MessageHelper.Instance().showError("Numbers Only Allowed", '' + errormsg); return false; } else { $("#btn_submit_" + prop.DocPropertyName).addClass('hidden'); } } else if (value == "") { $("#btn_submit_" + prop.DocPropertyName).addClass('hidden'); } }); var el = document.getElementById('txtOtp_' + prop.DocPropertyName); el.addEventListener('keydown', function (event) { const key = event.key; if (key === "Backspace" || key === "Delete") { $("#btn_submit_" + prop.DocPropertyName).addClass('hidden'); } }); if (callback != null) callback(); } loadControl(containerid, prop) { let ControlId = 'txt_' + prop.UniqueId; var regExpr = ""; var ErrMsg = ""; var validationlist = prop.Validations; if (validationlist != null) { for (var i = 0; i < validationlist.length; i++) { regExpr += validationlist[i].RegularExp + '||'; ErrMsg += validationlist[i].ErrorMessage + '||'; } } var Isrequired = prop.IsRequired != true ? 'hidden' : ''; var required = prop.IsRequired != true ? '' : 'required'; var reqMark = prop.IsRequired != true ? '' : '*'; var CurrentStageId = $("#hf_" + $("#hfLayout_InstalledPageId").val() + "_StageId").val(); if (prop.StagesForRequired != null) { var StagesForRequired = prop.StagesForRequired.split('|'); Isrequired = StagesForRequired.find(x => x == CurrentStageId) ? '' : 'hidden'; required = StagesForRequired.find(x => x == CurrentStageId) ? 'required' : ''; reqMark = StagesForRequired.find(x => x == CurrentStageId) ? '*' : ''; } const { helpTooltipHtml, helpTextHtml, helpClass } = Unibase.Platform.Forms.Components.FormViewer.Instance().getControlHelpHtml(prop); var html = `