if (/^[%*]/.test(document.getElementById("yourelementid").value))
alert("Where can I find a JavaScript tutorial?");
Run Code Online (Sandbox Code Playgroud)
作为解释:正则表达式/^[%*]/表示:
^ match the beginning of the string, followed immediately by
[%*] any one of the characters inside the brackets
Run Code Online (Sandbox Code Playgroud)
针对该正则表达式测试输入的值将返回true或false。
| 归档时间: |
|
| 查看次数: |
3366 次 |
| 最近记录: |