您当前的位置: 首页 > 

杨林伟

暂无认证

  • 2浏览

    0关注

    3337博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

32avalon - 指令ms-rules(自定义验证规则)

杨林伟 发布时间:2019-04-16 12:38:46 ,浏览量:2

直接上代码:


    var vm = avalon.define({
        $id: "validate2",
        firstname: '司徒正美',
        lastname: '',
        username: '',
        password: '',
        confirm_password: '',
        email: '',
        agree: false,
        topic: [],
        toggle: false,
        validate: {
            onError: function (reasons) {
                reasons.forEach(function (reason) {
                    console.log(reason.getMessage())
                })
            },
            onValidateAll: function (reasons) {
                if (reasons.length) {
                    console.log('有表单没有通过')
                } else {
                    console.log('全部通过')
                }
            }
        }
    })
    avalon.validators.checked = {
        message: '必须扣上',
        get: function (value, field, next) {
            next(value)
            return value
        }
    }
    avalon.validators.selecttwo = {
        message: '至少选择两个',
        get: function (value, field, next) {
            next(!vm.toggle || value.length >= 2)
            return value
        }
    }
   

    
验证完整的表单

名字

姓氏

用户名

密码

验证密码

Email

请同意我们的声明

我乐意接收新信息

主题 (至少选择两个) Marketflash Latest fuzz Mailing list digester 至少选择两个

关注
打赏
1662376985
查看更多评论
立即登录/注册

微信扫码登录

0.0601s