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/

猜你喜欢

转载自www.cnblogs.com/10manongit/p/12207779.html