验证输入的内容范围

$.extend($.fn.validatebox.defaults.rules, {
            telNum: { //既验证手机号,又验证座机号
                validator: function (value, param) {
                    return /(^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$)|(^((\d3\d3)|(\d{3}\-))?(1[358]\d{9})$)/.test(value);
                },
                message: '请输入正确的电话号码。'
            },
            specialCharacter:{
                validator: function (value, param) {
                    var reg = new RegExp("[`~!+#$^&*()=|{}':;'\\[\\]<>~!+#¥……&*()——|{}【】‘;:”“'、?]");
                    return !reg.test(value);
                },
                message: '不允许输入特殊字符'
            },
            chinese:{ 
                   validator : function(value, param) { 
                      var reg = /^[\u4e00-\u9fa5]+$/i; 
                       return reg.test(value); 
                   }, 
                   message: "请输入中文"
            },

        });

使用时在对应的textbox的html语句中加入data-options="validType:'email'"即可

你可能感兴趣的:(js)