vue validate js

时间:2020-06-05 22:47:23   收藏:0   阅读:49

 

export default class Validator {
    static required(val, msg) {
        if ((!val && val != 0) || val.length === 0) {
            throw msg
        }
        return this
    }

    static mobile(val) {
        if (!val || val.length !== 11 || !/^((13|14|15|17|18)[0-9]{1}\d{8})$/.test(val)) {
            throw 必须是11位手机号码
        }
        return this
    }
}

 

原文:https://www.cnblogs.com/fenle/p/13052246.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!