<!--pages/form/pages/rules/index.wxml-->
<view class='container'>
  <content-title name="Rules" describe="校验">
    <content-card class="content" name="基本案例">
      <view class='buttun-wrapper'>
        <form bindreset="formReset">
          <l-input label="邮箱" placeholder="请输入邮箱" label-width="170" name="email" rules="{{emailRules}}" tipType="message"/>
          <l-input label="用户名" placeholder="长度需要在12个字以内" label-width="170" name="user" rules="{{userRules}}" tipType="text" clear="{{true}}" l-error-text="error-text"/>
          <l-input label="密码" label-width="170" placeholder="请输入密码" name="password" rules="{{passwordRules}}" tipType="toast"/>
          <l-input label="手机号" label-width="170" placeholder="请输入手机号" name="phone" rules="{{phoneRules}}" tipType="toast"/>
          <view class="group-label">
            <text>爱好</text>
            <l-checkbox-group l-class="l-radio-group" rules="{{habbitRules}}" name="habbit" tipType="text" bind:linchange="changeCheckbox">
              <l-checkbox l-class="l-radio" l-title-class="l-title-class" placement="left" key="读书" checked="{{util.isChecked('读书',likes)}}">读书</l-checkbox>
              <l-checkbox l-class="l-radio" l-title-class="l-title-class" placement="left" key="写字" checked="{{util.isChecked('写字',likes)}}">写字</l-checkbox>
              <l-checkbox l-class="l-radio" l-title-class="l-title-class" placement="left" key="摄影" checked="{{util.isChecked('摄影',likes)}}">摄影</l-checkbox>
            </l-checkbox-group>
          </view>

          <view class="group-label">
            <text>性别</text>
            <l-radio-group l-class="l-radio-group" rules="{{sexRules}}" name="sex" tipType="text">
              <l-radio l-class="l-radio" l-title-class="l-title-class" placement="left" key="男" >男</l-radio>
              <l-radio l-class="l-radio" l-title-class="l-title-class" placement="left" key="女" >女</l-radio>
            </l-radio-group>
          </view>
          <text class="text-desc">* 输入你的自我介绍吧~~</text>
          <l-textarea l-class="textarea-class" placeholder="尽情展示自己..." tipType="text" name="detail" rules="{{userRules}}" />
        </form>
      </view>
    </content-card>
  </content-title>
</view>

<l-toast/>
<l-message/>

<wxs module="util">
  var isChecked = function(item,likes) {
    return likes.indexOf(item) > -1
  }
  module.exports = {
    isChecked: isChecked
  }
</wxs>
