validate.js
772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @fileOverview 发布组件
* @author:xmg
* @date:2013-01-14
*/
//邮箱检测
exports.isEmail = function (val)
{
var mailValid = /^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;
return mailValid.test(val);
};
//手机检测
exports.isMobile = function (val)
{
//var mobileValid = /^(1)([0-9]{10})$/;
var mobileValid = /^1[3|4|5|8][0-9]\d{8}$/ ;
return mobileValid.test(val);
};
//昵称检测
exports.isNickname = function (val)
{
var valid = /^[\u4E00-\u9FA5A-Za-z0-9_-]{2,32}$/;
return valid.test(val);
};
//是否整数
exports.isInt = function (val)
{
var mobileValid = /^\d$/ ;
return mobileValid.test(val);
};
//是否浮点数
exports.isFloat = function (val)
{
var mobileValid = /^\d+(\.\d+)?$/ ;
return mobileValid.test(val);
};