/**
* added by LxcJie 2004.6.25
* 去除多余空格函数
* trim:去除两边空格 lTrim:去除左空格 rTrim: 去除右空格
* 用法:
* var str = " hello ";
* str = str.trim();
*/
String.prototype.trim = function()
{
return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
String.prototype.lTrim = function()
{
return this.replace(/(^[\s]*)/g, "");
}
String.prototype.rTrim = function()
{
return this.replace(/([\s]*$)/g, "");
}
/********************************** Empty **************************************/
/**
*校验字符串是否为空
*返回值:
*假如不为空,定义校验通过,返回true
*假如为空,校验不通过,返回false 参考提示信息:输入域不能为空!
*/
function checkIsNotEmpty(str)
{
if(str.trim() == "")
return false;
else
return true;
}//~~~
/*--------------------------------- Empty --------------------------------------*/
/********************************** Integer *************************************/
/**
*校验字符串是否为整型
*返回值:
*假如为空,定义校验通过, 返回true
*假如字串全部为数字,校验通过,返回true
*假如校验不通过, 返回false 参考提示信息:输入域必须为数字!
*/
function checkIsInteger(str)
{
//假如为空,则通过校验
if(str == "")
return true;
if(/^(\-?)(\d )$/.test(str))
return true;
else
return false;
}//~~~
/**
*校验整型最小值
*str:要校验的串。 val:比较的值
*
*返回值:
*假如为空,定义校验通过, 返回true
*假如满足条件,大于等于给定值,校验通过,返回true
*假如小于给定值, 返回false 参考提示信息:输入域不能小于给定值!
*/
function checkIntegerMinValue(str,val)
{
//假如为空,则通过校验
评论加载中…
![]() |