- /*
- * 去除前后空白字符
- * @author yifangyou
- * @use " bv ".trim()
- * @version gslb 2011-01-16
- * */
- String.prototype.trim = function()
- {
- return this.replace(/(^\s*)|(\s*$)/g, "");
- }
- /*
- * 判断是否以某字符串结尾
- * @author yifangyou
- * @use " bv a".endswith("a")
- * @version gslb 2011-01-16
- * */
- String.prototype.endswith = function(findstr)
- {
- if(this.length-findstr.length<0){
- return false;
- }
- if(this.lastIndexOf(findstr)==this.length-findstr.length){
- return true;
- }
- return false;
- }
- /*
- * 只能输入英文数字.-下划线
- * @param str input的value
- * @use
- * @author yifangyou
- * @version gslb 2011-01-16
- * */
- function filterchar(str){
- var p=/[^\w\-\.]/g
- return str.replace(p,'');
- }
- /*
- * 过滤特殊字符
- * @param str input的value
- * @use
- * @author yifangyou
- * @version gslb 2011-01-16
- * */
- function filterschar(str){
- var p=/[\'\"#,;&%^\$!\+=\|\\\/ ]/g
- return str.replace(p,'');
- }
- /*
- * 过滤特殊字符 剔除,\除外
- * @param str input的value
- * @use
- * @author yifangyou
- * @version gslb 2011-01-16
- * */
- function filterschar2(str){
- var p=/[\'\"#,;&%^\$!\+=\|\\ ]/g
- return str.replace(p,'');
- }
- /*
- * 过滤中文和特殊字符
- * @param str input的value
- * @use
- * @author yifangyou
- * @version gslb 2011-01-16
- * */
- function filterchinese(str){
- var p=/[\u4E00-\u9FA5\'\",&%^\$!\+=\|\\\/]/g
- return str.replace(p,'');
- }
- /*
- * 只允许输入中英文 "_" "-"
- * @param str input的value
- * @use
- * @author yifangyou
- * @version gslb 2011-01-16
- * */
- function filterOnlyCE(str){
- var p=/[^\u4E00-\u9FA5\w\-]/g
- return str.replace(p,'');
- }
- /*
- * 只能输入数字
- * @param str input的value
- * @use
- * @author yifangyou
- * @version gslb 2011-01-16
- * */
- function filterNumeric(str){
- var p=/[\D]/g
- return str.replace(p,'
end09-15 11:48