只能輸入數字

http://m.jb51.net/article/83398.htmthis

第一: 限制只能是整數spa

<input type = "text" name= "number" id = 'number' onkeyup= "if(! /^d+$/.test(this.value)){alert('只能整數');this.value='';}" />

第二: 限制是兩位的小數.net

<input type = "text" name= "price" id = 'price' onkeyup= "if( ! /^d*(?:.d{0,2})?$/.test(this.value)){alert('只能輸入數字,小數點後只能保留兩位');this.value='';}" />
相關文章
相關標籤/搜索