惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
Y
Y Combinator Blog
博客园 - 【当耐特】
V
Visual Studio Blog
GbyAI
GbyAI
V
V2EX
P
Proofpoint News Feed
Microsoft Azure Blog
Microsoft Azure Blog
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
aimingoo的专栏
aimingoo的专栏
B
Blog RSS Feed
量子位
MongoDB | Blog
MongoDB | Blog
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件

博客园 - 心的感觉

office 2007 下 PDFMaker文件遗失 问题解决办法 PL/SQL 连接Oracle10g失败 document.all.WebBrowser为空或不是对象 同事发的,很感人的一篇文章,记录下来,洁净心灵 有用的两个快捷方式/VS及dreamweaver怎么把源码排列整齐 div隐藏的两种方式 自己遇到oracle的错误记录 怎么彻底删除oracle 清空Oracle 10g回收站中以BIN$开头的表 PowerDesigner12 菜单翻译 innerHTML,outerHTML,innerText,outerText的区别和用法 PowerDesigner 帮助文档 漂亮的周涛 GridView表头出现乱码而正文正常的问题 PowerDesigner教程系列(六)概念数据模型 PowerDesigner教程系列(五)概念数据模型 PowerDesigner教程系列(四)概念数据模型 PowerDesigner教程系列(三)概念数据模型 PowerDesigner教程系列(二)概念数据模型
有用的正则表达式或JS方法
心的感觉 · 2009-06-11 · via 博客园 - 心的感觉

1、限制文本框只能输入汉字、字母和数字

js里方法:

         function rep(obj)
        { 

            //加上这一句的作用是为了方向键能用
            if(event.keyCode==37||event.keyCode==39) return;           
            obj.value=obj.value.replace(/[^\w\u4E00-\u9FA5]/g, '');
        }

调用:

前台:

onkeyup="rep(this);

后台方法:

this.txtName.Attributes.Add("onKeyup", "rep(this);");

2、限制文本框输入长度

        //字符长度
        function textLimitCheck(thisArea, maxLength)
        {
            if (thisArea.value.length > maxLength)
            {
                alert(maxLength + ' 个字限制. \r超出的将自动去除!');
                thisArea.value = thisArea.value.substring(0, maxLength);
                thisArea.focus();
            }
        }

 3、js的四舍五入的函数用法

<html>
<head><title>ssss</title></head>
<script>
 function toFix(idvalue){
 alert(parseFloat(idvalue).toFixed(2));//2表示保留2位小數
 
 
 }
</script>
<body>
<table><tr><td>
 <input type="text" name="aaa" onchange="toFix(this.value)">
</td></tr></table>
</body>
</html>