繁体   English   中英

Javascript 在 azure ad b2c 自定义注册页面中不起作用

[英]Javascript not working in azure ad b2c custom sign-up page

我在 azure ad b2c 中创建了自定义注册页面,但 javascript 不起作用。

我还在属性中启用了 [Enable JavaScript enforcing page layout] 选项,

***目前我使用的是用户流而不是自定义策略

自定义页面示例:

<!DOCTYPE html>
<!-- saved from url=(0080)../assets/AzureBlue/selfAsserted.cshtml -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <title>Sign up</title>

    
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" type="text/css" />

    <link href="https://demostorage.z11.web.core.windows.net/slate_gray/css/assets.css" rel="stylesheet" type="text/css" />
    <link href="https://demostorage.z11.web.core.windows.net/slate_gray/css/common.css" rel="stylesheet" type="text/css" />
    <link href="https://demostorage.z11.web.core.windows.net/slate_gray/css/selfasserted.css" rel="stylesheet" type="text/css" />

    <style>
        .tnc-container {
            height: 100px; 
            overflow-y: scroll;
            text-align: left !important;
            border: 1px gray solid;
            padding: 5px;
            margin: 20px 0px 0px 0px;
        }

        .buttons #continue {
            float: none !important;
        }
    </style>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var checkbox = document.querySelector("input[type=checkbox]");
            checkbox.addEventListener( 'change', function(e) {
                var currentdate = new Date(); 
                var datetime = currentdate.getFullYear() + "/"
                                + (currentdate.getMonth()+1)  + "/" 
                                + currentdate.getDate() + " "  
                                + currentdate.getHours() + ":"  
                                + currentdate.getMinutes() + ":" 
                                + currentdate.getSeconds();

                this.value = datetime;
            });
        }, false);
    </script>

</head>
<body>
    <div class="container  self_asserted_container ">
        <div class="row">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <img alt="Company Logo" class="companyLogo" src="https://demostorage.z11.web.core.windows.net/assets/images/logo.svg">
                        <div id="api">
                        </div>
                        <div class="tnc-container">
                            <b>Terms and Conditions Sample Generator</b> <br>
Help protect your website and its users with clear and fair website terms and conditions. These terms and conditions for a website set out key issues such as acceptable use, privacy, cookies, registration and passwords, intellectual property, links to other sites, termination and disclaimers of responsibility. Terms and conditions are used and necessary to protect a website owner from liability of a user relying on the information or the goods provided from the site then suffering a loss.

Making your own terms and conditions for your website is hard, not impossible, to do. It can take a few hours to few days for a person with no legal background to make. But worry no more; we are here to help you out.

All you need to do is fill up the blank spaces and then you will receive an email with your personalized terms and conditions.
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


</body></html>

我已经在本地测试了这个 javascript ......它工作正常。

使用 javascript 功能,我想将当前日期时间存储在复选框“服务团队同意”检查中

您可以使用CombinedSignUpAndSignIn策略,您可以通过以下过程显示复选框

转到用户流属性。

  1. 选择Page layout
  2. 选择“本地帐户注册页面”。
  3. User Attributes ,找到应该是布尔值的属性。
  4. User input type设置为CheckboxMultiSelect

然后转到用户流程中的语言菜单。

  1. 启用Language Customisation
  2. 下载'Local account sign up page'的英文默认语言文件。
  3. "LocalizedCollections"查找扩展属性名称。
  4. 添加一个值,如下所示:

https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-language-customization#provide-a-list-of-values-by-using-localizedcollections

  "Items":[
{
     "Name":"Agree",
     "Value":"True"
}

保存您的文件并将其上传为英文本地化的覆盖。 您现在应该会看到复选框,选中时它将返回True ,未选中时返回False

在此处输入图片说明

有一个与此相关的示例,它显示一个复选框,并写入所显示的 TOU版本

TOU 需要由您的HTML 自定义提供,或者您可以将其写在paragraph 声明中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM