码迷,mamicode.com
首页 > Web开发 > 详细

js只能输入数字、汉字、字母等正则匹配

时间:2016-01-08 18:51:15      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:

        只能输英文:<input type="text" onkeyup="value=value.replace(/[^a-zA-Z]/g,‘‘)">
        只能输入汉字:<input onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,‘‘)" onbeforepaste="clipboardData.setData(‘text‘,clipboardData.getData(‘text‘).replace(/[^\u4E00-\u9FA5]/g,‘‘))">
        只能输入英文、数字、@符号和.<>?\:符号:<input type="text" onkeyup="value=value.replace(/[^a-za-z0-9u4e00-u9fa5.@]/g,‘‘)"><br><br>
        只能输入英文字母和数字,不能输入中文:<input onkeyup="value=value.replace(/[^\w\/]/ig,‘‘)"><br><br>
        只能输入数字、字母、下划线:<input ID="txtShopNumber" runat="server" class="input_text" onkeyup="value=value.replace(/[^(\-)\w\.\/]/ig,‘‘)"/>
        只能输入数字的:<input onkeyup="value=value.replace(/[^\d]/g,‘‘) " onbeforepaste="clipboardData.setData(‘text‘,clipboardData.getData(‘text‘).replace(/[^\d]/g,‘‘))" ID="Text2">

 

js只能输入数字、汉字、字母等正则匹配

标签:

原文地址:http://www.cnblogs.com/yingzi1028/p/5114112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!