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

  • SEARCH
  • Home
  • 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 6250697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:28:29+00:00 2026-05-24T13:28:29+00:00

Aloha! Trying to run a basic validation on a postal code input, and additionally

  • 0

Aloha!

Trying to run a basic validation on a postal code input, and additionally check the entered value to see if it exists in a keyless JSON array.
Everything works as expected until I add the remote function. If possible, I’d like to utilize this function, since it is built in, but I am open to other methods of validation.

Working example of this, without remote, here: http://jsfiddle.net/sangria/xLGae/

Likely unrelated, but getting this error in the console on submit:

Uncaught Error: NOT_FOUND_ERR: DOM Exception 8

JSON array format:

[94102,94117,94110,99950,...]

jQuery and Validation:

jQuery.validator.addMethod("postalcode", function(postalcode, element) {
    return this.optional(element) || postalcode.match(/^([0-9]{5})$/);
}, "Please specify a valid postal/zip code");

$("#postal").validate({
    rules: {
        zipcode: {
            required: true,
            postalcode: true,
            digits: true,
            minlength: 5,
            maxlength: 5,
            remote: {
                type: 'post',
                contentType: 'application/json; charset=utf-8',
                url: "data/uszipsonly.json",
                dataType: 'json',
                async: false
            }
        }
    },
    messages: {
        zipcode: { remote: "Please specify a US postal code"}
    }
});

Pored over the docs and some other good examples. Found similar threads here on SO, but still somewhat tripped up by this.

Much thanks to the community for any enlightenment.

  • 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-24T13:28:30+00:00Added an answer on May 24, 2026 at 1:28 pm

    If you are using the jquery.bassistance.de like I think maybe you mis-interpreted the role of the remote feature..

    Basically remote can only return true/false after being sent the value and is intended mainly for rules were you don’t want the accepted value to be stored on the client, EVER (think of captcha for example) like in here http://jquery.bassistance.de/validate/demo/captcha/

    If you want to download the list of possible ZIP code your app accept (or does not accept) from your server I suggest doing the following:

    $.getJSON("data/uszipsonly.json", function(response) {
    var validZIP = response;
    
    jQuery.validator.addMethod("postalcode", function(postalcode, element) {
        return this.optional(element) || (postalcode.match(/^([0-9]{5})$/) && $.inArray(postalcode, validZIP));
    }, "Please specify a valid postal/zip code");
    

    })

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

Sidebar

Related Questions

I am trying to run this code OBVMA <- function(price,volume,n) { price <- try.xts(price,
I'm trying to find a decent IDE that supports Python 3.x, and offers code
I'm trying to dynamically add Images to a ScrollView. Before adding I check if
Im getting this error when trying to run a program in creating, how shold
I'm trying to modulate an alpha value in a Java application I'm building on
I'm trying to process an RGBA buffer (list of chars) , and run unpremultiply
I'm trying to understand why the code below changes the QImage in Qt. It's
I'm trying to write a simple Ubiquity command that will run a query on
Aloha, I'm trying to populate a treeview on a windows form app with Hierarchical
I'm trying to animate the alpha value of the text in a tableview cell.

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.