Files
youfang-app/fangija-zsyf/js/validate.js
T
xuhe@fangjia.com 4531427300 aa
2018-03-13 15:27:44 +08:00

39 lines
1.1 KiB
JavaScript

/**
* 扩展Jquery 新增validate
*/
(function ($) {
$.isMobile = function (text) {
return $.trim(text) != "" && /^1[3|4|5|7|8][0-9]\d{8}$/.test(text);
}
$.isBlank = function (text) {
return $.trim(text) == "";
}
$.isLengthEq = function (text) {
return $.trim(text) != "" && text.length == 4;
}
$.isPositiveInteger = function (text) {
return $.trim(text) != "" && /^\d+$/.test(text);
}
$.isPositiveFloat = function (text) {
return $.trim(text) != "" && /^\d+(\.\d+)?$/.test(text);
}
$.fn.isMobile = function () {
return $.isMobile($.trim(this.val()));
}
$.fn.isBlank = function () {
if ($.trim(this.val()) == "") {
return true;
}
return false;
}
$.fn.lengthEq = function (length) {
return $.trim(this.val()) != "" && this.val().length == 4;
}
$.fn.isPositiveInteger = function () {
return $.isPositiveInteger($.trim(this.val()));
}
$.fn.isPositiveFloat = function () {
return $.isPositiveFloat($.trim(this.val()));
}
})($)