validator API文档

如何使用

引入

<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../dist/script/ux-form.js"></script>

html

<div class="container">
    <div>
        <label>姓名<input type="text" name="name" /></label>
    </div>
</div>

javascript

var nameFormControl = uxForm.FormControl.create($('[name=name]'), {
    required: true,
    rules: {
        maxLength: 20
    },
    patterns: {
        maxLength: 20
    }
});

nameFormControl.obs.on('onCheck',function(){
    console.log(nameFormControl.getStatus());
});

https://jsfiddle.net/mqc686cx/4/

    原文作者:gibsonxiong
    原文地址: https://segmentfault.com/a/1190000011428552
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞