私は2つの異なるフィールドの正規表現を持っています。どちらも正しい値を評価しますが、ユーザーが空白を入力できないようにします。たとえば、Genderフィールドのユーザーは、単に空白を入力してフォームを送信できます。私は空白を入力するのを防ぐためにしたい。ここに私の正規表現です:HTML5のパターン正規表現は空白を防ぎますか?
Gender pattern="*[MmFf]?*" #This field should allow M or F letter lower or upper case. Nothing else should be allowed. This field is 1 character only.
Grade pattern=" *(0?[0-9]|1[0-2]|[A-Z]{1,2})? *" #This should allow 01 or 1 and something like this PK or pk. No white space.
私はHTML5パターンの空白を防ぐ方法がわかりません。誰かがこの問題を解決する方法を知っていれば教えてください。ありがとう。
可能重複[正規表現正規表現の検証に空白を防ぐ方法(https://stackoverflow.com/questions/2842823/how-to -prevent-white-spaces-in-a-regular-expression-regex-validation) – marcusshep