JS判断input输入类型

只能输入数字:<input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />

只能输入数字和小数点:<input onkeyup="value=value.replace(/[^\d\.]/g,'')">

只能输入英文和数字:<input onkeyup="value=value.replace(/[\W]/g,'') "onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))">

 

posted @ 2014-03-14 15:14  Damon.Wu  阅读(2583)  评论(0编辑  收藏  举报