Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6365295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:16:32+00:00 2026-05-25T00:16:32+00:00

Actually, I want to validate the Canadian postal code form field using jQuery validation.

  • 0

Actually, I want to validate the Canadian postal code form field using jQuery validation.

so i add the below method to validate Canadian postal code

//Canada zipcode validation methode 
    jQuery.validator.addMethod("canadazipRegex", function(value, element) {
            return this.optional(element) || /^[ABCEGHJ-NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[ ]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$/i.test(value);
    }, "<br>You must enter your postal code in this format: A#A  #A#");

using this regular Expression

^[ABCEGHJ-NPRSTVXY]{1}[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[
]?[0-9]{1}[ABCEGHJ-NPRSTV-Z]{1}[0-9]{1}$

the field should allow only this format

A#A #A#

like :A1A 1A1

Not like:A1A1A1

So,How can i make sure white space after 3 characters.

I am not good with regular Expressions. if you give me good tutorial links also appreciated

Thanks in advance !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:16:32+00:00Added an answer on May 25, 2026 at 12:16 am

    Don’t make the space optional :

    ^[ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z]\s[0-9][ABCEGHJ-NPRSTV-Z][0-9]$
    

    Also there are no needs to use quantifier {1}

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using jQuery validate and I don't want the form to validate when
Im using asp.net webforms. c# I want to validate a form. In the codebehind
I am using jQuery to create a client-side validation function for a .NET form.
I want to validate a registration form that accepts an email address in the
I'm trying to use jQuery inside a Firefox extension, and actually want to use
Actually I want to validate username nd password only for my os1 == 2
How do I enumerate the properties of a JavaScript object? I actually want to
I have a JPEG image (actually a BLOB in a database) which I want
Actually, I'm using this way. Do you have a better way? private bool AcceptJson(HttpRequest
I'd like to use System.Net.IPAddress.TryParse to validate IPv6 addresses because I don't want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.