看板 Ajax 關於我們 聯絡資訊
遇到一個問題想請問一下版上先進 我有個 input <input onkeyup="return ValidateFloat(this)" value=''/> function 如下 function ValidateFloat( e ) { if (!/^[???]+$/.test(e.value)) e.value = /^[???]+$/.exec(e.value); } 目的是想要讓使用者只能輸入 英文 or 數字 or _ or - 例如 abc-123_456 -> true 所以問題是想請問 /^[???]+$/.exec(e.value); 這裡應該要怎麼更改呢? 謝謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.173.96.196 ※ 文章網址: http://www.ptt.cc/bbs/Ajax/M.1418029268.A.7D5.html ※ 編輯: kiey (1.173.96.196), 12/08/2014 17:03:53
kiey: 使用 /^[a-zA-Z0-9\-\_]+$/ 如果輸入不符合的字串整個 input 12/08 17:07
kiey: 都會變空白 12/08 17:07