Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
テキスト ボックスがあり、以下に示すように 2 つの単語の間にコンマを使用できないことを確認する必要があります (例: B521,Baraghat)。そのためにregextが必要です。JavaScriptでそれを行う方法。
このチェックには正規表現は必要ありません。これにより、文字列にコンマが含まれていないことが確認されます。
if(str.indexOf(',') != -1) { <Invalid string logic> }
正規表現を主張する場合:
if(str.match(/\,/)) { <invalid string logic> }