Validate Canadian Postal Code Regex

后端 未结 7 2271
[愿得一人]
[愿得一人] 2021-02-20 07:12

I have a script written in JavaScript to Validate Canadian Postal Codes using Regex, however it does not seem to be working. Here is the script:

If statement:

         


        
7条回答
  •  情书的邮戳
    2021-02-20 07:50

    This will do for Canadian postal code:

    /^[a-z][0-9][a-z][- ]?[0-9][a-z][0-9]$/i
    

    It will allow for the proper X#X #X# format with a space or hyphen.

提交回复
热议问题