---
title: "activate_customer_password_form"

doc_type: static
doc_category: static
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/sline/tag/activate-customer-password-form'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/sline/tag/activate-customer-password-form.md'
---

# activate_customer_password_form


    生成账号激活表单。商家向未激活账号的客户发送邀请邮件后，客户点击邮件中的账号激活链接进入激活页面，设置密码后即可激活账号。

    ## 表单输入

**customer[password]** string **required**

密码。

最大长度限制：40

最小长度限制：5

**customer[accepts_marketing]** boolean

客户是否接受营销电子邮件。
- `true`：接受
- `false`：不接受



```sline
{{#activate_customer_password_form}}
    form_content
{{/activate_customer_password_form}}
```









    
## 例子

        
            

            以下示例用于生成一个客户账号激活表单。

            

            
<SlineExample path={'/user/activate'} objects={ 
    [""] 
}>
```sline
{{#activate_customer_password_form id="customer-activate-form"}}
<div class="password">
  <label for="customer[password]">user password</label>
  <input type="password" name="customer[password]" placeholder="user password" />
</div>

<div class="accepts-marketing">
  <input type="checkbox" name="customer[accepts_marketing]" value="true">
  <label for="accepts-marketing">Subscribe to email marketing</label>
</div>

<div class="submit">
  <input class="submit-button" type="submit" value="Submit">
</div>
{{/activate_customer_password_form}}

<script>
class Activate {
  constructor() {
    this.form = document.querySelector('#customer-activate-form');
    this.form.addEventListener('submit', this.onSubmitHandler.bind(this));

    this.activate = new window.Shopline.customerAccount.Activate(this.form)
  }

  onSubmitHandler(e) {
    e.preventDefault();

    this.activate.submit()
      .then(response => {
        window.location.href = '/user/signIn';
      })
      .catch(error => {
        // Handling failure
        console.log(error)
      })
  }
}

// Initializing the JS SDK
window.Shopline.loadFeatures(
  [
    {
      name: 'customer-account-api',
      version: '0.3'
    }
  ],
  function(error) {
    if (error) {
      throw error;
    }
    new Activate();
  }
);
</script>
```
</SlineExample>
            
        
    
