validate.js 770 Bytes
/**
 * @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)
{
	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);
};