JavaScript公用函数
来源:互联网 发布:股票资金流向软件 编辑:程序博客网 时间:2024/04/30 19:25
<script language=javascript>
//去全部空格
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, "");
}
//验证是否为不带小数点正整数
String.prototype.isPositiveInteger = function(){
return /^/+?/d+$/.exec( this )
}
//验证是否为不带小数点负整数
String.prototype.isNegativeInteger = function(){
return /^/-?/d+$/.exec( this )
}
//验证是否为整数(不带小数点)
String.prototype.isInteger = function(){
return /^(/-|/+)?/d+$/.exec( this )
}
//验证是否为整数 正数
String.prototype.isPositiveDecimal = function(){
return /^/+?/d+(/./d+)?$/.exec( this )
}
//验证是否为整数 负数
String.prototype.isNegativeDecimal = function(){
return /^/-/d+(/./d+)?$/.exec( this )
}
//验证是否为整数 (带小数点)
String.prototype.isDecimal = function(){
return /^(/-|/+)?/d+(/./d+)?$/.exec( this )
}
//验证是否为大写字母
String.prototype.isCapital = function(){
return /^[A-Z]+$/.exec( this )
}
//验证是否为小写字母
String.prototype.isLowercase = function(){
return /^[a-z]+$/.exec( this )
}
//合并字符串
function StringBuffer(){
this._strings_ = new Array;
StringBuffer.prototype.append = function( str ){
this._strings_.push( str );
}
StringBuffer.prototype.tostring = function(){
return this._strings_.join( "" );
}
}
</script>
未完
- JavaScript公用函数
- 公用函数
- 公用函数
- 一些公用js函数
- 公用函数(1)
- 我的公用函数
- delphi公用函数
- 公用sqlcommand 函数
- ajax请求公用函数
- delphi公用函数
- asp 自用 公用函数
- thinkphp3.2.2公用函数
- Javascript------魅族官网公用 js 收集
- 系统公用函数及过程
- 三层结构的公用函数
- 一些公用函数的集合
- HTML5本地化存储公用函数
- (转)WinINet中的公用函数
- 优化C语言代码常用的几招
- 写给即将步入大学,主修计算机专业的青年们的一封信
- blog开张了
- tablespace occuped with autoextent managment and tempfile
- 快速安装虚拟机上的ubuntu服务器环境
- JavaScript公用函数
- Sql tricks: multiple rows in one output value
- linux下一些软件的中文显示问题
- 使用DriverStudio开发WDM设备驱动程序入门
- linux下批量处理文件内容
- Raw Socket(原始套接字)实现Sniffer(嗅探)
- 类似QQ右下角消息提示---自动隐藏。不大适合
- 类似QQ右下角消息提示2--自动刷新
- 类似QQ右下角消息提示3