Home > Article > Web Front-end > jquery data validation plug-in (self-made, simple, practice) example code_jquery
}
//验证手机是否符合格式
$.fn.RegMombilePhone = function(options) {
var rexString = /(^189\d{8}$)|(^13\d{9}$)|(^15\d{9}$)/;
return UiProcess(options, rexString, this)
}
//验证中文是否符合格式
$.fn.RegCHZN = function(options) {
var rexString = /[\u4e00-\u9fa5]/;
return UiProcess(options, rexString, this)
}
//验证decimal是否符合格式
$.fn.RegDecimal = function(options) {
var rexString = /^[0-9]+[.]?[0-9]+$/;
return UiProcess(options, rexString, this)
}
//验证decimal保留一位小数是否符合格式
$.fn.RegDecimalSign = function(options) {
var rexString = /^[+-]?[0-9]+[.]?[0-9]+$/;
return UiProcess(options, rexString, this)
}
//验证整数保留一位小数是否符合格式
$.fn.RegNumber = function(options) {
var rexString = /^[0-9]+$/;
return UiProcess(options, rexString, this)
}
//验证各位整数保留一位小数是否符合格式
$.fn.RegNumberSign = function(options) {
var rexString = /^[+-]?[0-9]+$/;
return UiProcess(options, rexString, this)
}
//验证非空字符
$.fn.IsEmpty = function(options) {
var rexString = /(^.+$)|([\u4e00-\u9fa5])/;
return UiProcess(options, rexString, this)
}
})(jQuery);
Call: