【发布时间】:2015-04-13 10:53:32
【问题描述】:
在 if 语句中,我想检查字符串中是否有标点符号。如果它有标点符号,我想弹出一条警告消息。
if((/*regex presumably*/.test(rspace))==true||(/*regex presumably*/.test(sspace))==true){
alert('Please enter your guessed answer in the fields provided, without punctuation marks.');
//if only punctuation are entered by the user, an alert message tells them to enter something.
}
我是否需要正则表达式,或者是否有自动方法可以为我执行此操作? 提前致谢!
【问题讨论】:
-
这可能会有所帮助:stackoverflow.com/a/13840211/3894168
标签: javascript if-statement punctuation