www.webdeveloper.com
Results 1 to 5 of 5

Thread: Postal Code validation (Canadian)

Hybrid View

  1. #1
    Join Date
    May 2010
    Posts
    5

    Exclamation Postal Code validation (Canadian)

    I am using

    <script>
    function Validate()
    {
    var regEx = /[a-zA-Z][0-9][a-zA-Z](-| |)[0-9][a-zA-Z][0-9]/;
    if(regEx.test())
    {
    alert('Valid Postal Code');
    }
    else
    {
    alert('Invalid Postal Code');
    }
    }

    </script>

    to validate the postal code with an onBlur function for some reason even if i type in a valid postal code it comes as invalid. Can anyone clarify why?

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415
    What constitutes a valid Canadian postal code?

  3. #3
    Join Date
    May 2010
    Posts
    5
    there are certain letters that are not in but as far as i am concerned it is a "a#a#a#" or "a#a #a#" format

  4. #4
    Join Date
    May 2010
    Posts
    5
    Quote Originally Posted by Ghuzarish View Post
    I am using

    <script>
    function Validate()
    {
    var regEx = /[a-zA-Z][0-9][a-zA-Z](-| |)[0-9][a-zA-Z][0-9]/;
    if(regEx.test())
    {
    alert('Valid Postal Code');
    }
    else
    {
    alert('Invalid Postal Code');
    }
    }

    </script>

    to validate the postal code with an onBlur function for some reason even if i type in a valid postal code it comes as invalid. Can anyone clarify why?
    Resolved

  5. #5
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,415

    Question

    Quote Originally Posted by Ghuzarish View Post
    Resolved
    What was your fix?
    Others might be interested in the solution.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles