Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1892706
  • 博文数量: 606
  • 博客积分: 9991
  • 博客等级: 中将
  • 技术积分: 5725
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-17 19:07
文章分类

全部博文(606)

文章存档

2011年(10)

2010年(67)

2009年(155)

2008年(386)

分类:

2008-12-16 13:05:24

  /**
* 验证普通字串,只要字串中不包含特殊字符即可
*/
function checkTextDataForNORMAL(strValue)
{
// 特殊字符验证格式
var regTextChar = /([\*\"\'<>\/])+/ ;
return !regTextChar.test(strValue);
}

/**
* 验证整数,包含正整数和负整数
*/
function checkTextDataForINTEGER(strValue)
{
var regTextInteger = /^(-|\+)?(\d)*$/;
return regTextInteger.test(strValue);
}

/**
* 检查是否为正整数 
*/
function isUnsignedInteger(strInteger) 

  var newPar=/^\d+$/ 
  return newPar.test(strInteger); 
}

function checkMoney(strValue, strUnit)
{
var testMoney = eval("/^\\d+(\\.\\d{0," + (strUnit.length -1) + "})?$/");
return testMoney.test(strValue);
}

/**
* 验证浮点数
*/
function checkTextDataForFLOAT(strValue)
{
var regTextFloat = /^(-)?(\d)*(\.)?(\d)*$/;
return regTextFloat.test(strValue);
}

/**
* 验证数字
*/
function checkTextDataForNUMBER(strValue)
{
var regTextNumber = /^(\d)*$/;
return regTextNumber.test(strValue);
}

/**
* 验证英文字母,不区分大小写
*/
function checkTextDataForENGLISH(strValue)
{
var regTextEnglish = /^[a-zA-Z]*$/;
return regTextEnglish.test(strValue);
}

/**
* 验证大写英文字母
*/
function checkTextDataForENGLISHUCASE(strValue)
{
var regTextEnglishUCase = /^[A-Z]*$/;
return regTextEnglishUCase.test(strValue);
}

/**
* 验证小写英文字母
*/
function checkTextDataForENGLISHLCASE(strValue)
{
var regTextEnglishLCase = /^[a-z]*$/;
return regTextEnglishLCase.test(strValue);
}

/**
* 验证英文字母和数字,不区分大小写
*/
function checkTextDataForENGLISHNUMBER(strValue)
{
var regTextEnglishNumber = /^[a-zA-Z0-9]*$/;
return regTextEnglishNumber.test(strValue);
}

/**
* 验证时间
*/
function checkTextDataForTIME(strValue)
{
var regTextTime = /^(\d+):(\d{1,2}):(\d{1,2})$/;
return regTextTime.test(strValue);
}

/**
* 验证电话号码
*/
function checkTextDataForPHONE(strValue)
{
var regTextPhone = /^(\(\d+\))*(\d)+(-(\d)+)*$/;
return regTextPhone.test(strValue);
}

/**
* 验证EMail
*/
function checkTextDataForEMAIL(strValue)
{
var regTextEmail = /^[\w-]+@[\w-]+(\.(\w)+)*(\.(\w){2,3})$/;
return regTextEmail.test(strValue);
}

/**
* 验证URL
*/
function checkTextDataForURL(strValue)
{
var regTextUrl = /^(file|http|https|ftp|mms|telnet|news|wais|mailto):\/\/(.+)$/;
return regTextUrl.test(strValue);
}

/**
* 验证邮政编码
*/
function checkTextDataForPOST(strValue)
{
var regTextPost = /^(\d){6}$/;
return regTextPost.test(strValue);
}
阅读(461) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~