看板 RegExp 關於我們 聯絡資訊
我有一個表單中的一個欄位, 我想限制他只能輸入特定文字, 如果鍵入其他文字 會被replace為空白(ex:1,2,3,A,B,C,*) 原始寫法如下: this.value = this.value.replace(/[^123ABC*]/,''); 裡面的123ABC* 改為利用php撈資料庫的方式串成一串字串 想法如下: var 變數=new RegExp('<?php echo $string?>',"g"); this.value = this.value.replace(/[^變數]/,''); php的$string已經處理好, 值為 '123ABC*' 請問這個 '變數' 要如何填寫? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.222.206.165 ※ 文章網址: https://www.ptt.cc/bbs/RegExp/M.1486965690.A.47B.html
mars90226: 請用RegExp class 02/13 23:46
mars90226: https://goo.gl/C4Z4XN MDN 關於 RegExp 的文件 02/13 23:47