This commit is contained in:
xuhe@fangjia.com
2018-03-13 15:27:44 +08:00
parent 1568fe51f7
commit 4531427300
10 changed files with 14932 additions and 1081 deletions
+39
View File
@@ -0,0 +1,39 @@
/**
* 扩展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()));
}
})($)