JavaScript无法在azure ad b2c自定义注册页面中使用

时间:2020-10-29 06:08:45

标签: javascript azure azure-ad-b2c

我已经在azure广告b2c中创建了自定义注册页面,但是javascript无法正常工作。

我还在属性中启用了[启用JavaScript强制页面布局]选项,

***当前我正在使用用户流而非自定义策略

自定义页面示例:

<!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函数,我想在“服务团队同意”复选框中存储当前日期时间

1 个答案:

答案 0 :(得分:0)

您可以使用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

enter image description here

与此相关的sample提供了一个复选框,并编写了所显示的TOU的版本

TOU需要由您的HTML customisation提供,或者您可以将其写入paragraph claim