• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

Javascript alphanumeric postal code Not checking !

Hi experts,

I'm looking for javascript alphanumeric postal code validate in my list of array postalcode only.. I attached in my sample code, but it not checked alphanumeric value only checking numeric value.. Plz guide me what mistake in my code..

Thanks,
test-zipcode.html
0
codeoxygen
Asked:
codeoxygen
  • 4
  • 4
1 Solution
 
Julian HansenCommented:
Code seems fine if you want to check for postal codes that are exactly 5 digits long but you said alpha-numeric postal codes.

Your regular expression is only checking for digits - not alphas.

What are the possible inputs with respect to your postal codes that you want to validate for?
0
 
codeoxygenAuthor Commented:
Example : var codes = ["SO15 0HX","SO15 0HY"];

i want to check only two alphanumeric postal code only ("SO15 0HX","SO15 0HY").

1. if enter code contain only numeric or only letters
{ alert("Postal code not valid") }
2. Or enter alphanumeric either of correctly ("SO15 0HX","SO15 0HY") go to other page..
3. Or enter alphanumeric is wrong of (ex. S015 00X) {alert ("postal code is not found").

How i make that possibilities in my code?
0
 
Julian HansenCommented:
So are there only two correct postal codes?

If this is the case why not have a radio button or drop down for this selection or have a check

if (postal_code != "SO15 0HX" && postal_code != "SO15 0HY") ...

Or are there potentially other valid codes?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
codeoxygenAuthor Commented:
No. i check "n" number of postal code  in that array of like
var codes = ["SO15 0HX","SO15 0HY","",......];
0
 
Julian HansenCommented:
If they are fixed then why not have them in a drop down?
0
 
codeoxygenAuthor Commented:
It's fixed  but 400 + postal code want to check. so dropdown goes to lengthy., so i'm looking to checking list of array fixed value's using javascript? it's possible..
0
 
codeoxygenAuthor Commented:
http://jsfiddle.net/Wgrtv/

i got a solution here..
0
 
Julian HansenCommented:
Yes that will work - in future describe your problem a bit better - the problem as presented was using a regular expression with no mention of an array of postal codes. By giving more information you can help experts give you the answer you need quicker.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now