title: validation input zipcode Mexico zippopotam
body: <p>I need to validate the zip code if is true of Mexico.</p>
  
  <p>I have a form and you can see the code next, I don't understand why don't consider the validation, what is wrong?</p>
  
  <p>I pasted the code of an example I found</p>
  
  <p><a href="http://parsleyjs.org/doc/examples/ajax.html" rel="nofollow noreferrer">http://parsleyjs.org/doc/examples/ajax.html</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// on js
  Parsley.addValidator('zip', {
              validateString: function (value) {
                  // Zippopotam.us returns a status 404 for incorrect zip codes,
                  // so we simply return the ajax request:
                  return $.ajax({
                      url: '//www.zippopotam.us/mx/' + value,
                      success: function (result, success) {
                          $('#zipState').val(result['places'][0]['state abbreviation']);
                      },
                      error: function (result, success) {
                          $('#zipState').val('');
                      }
                  })
              }
          });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>//input in form
    &lt;div class="consumidor_cp_right"&gt;
    &lt;div class="consumidor_cp"&gt;
   &lt;label for="zip"&gt;&lt;span&gt;*&lt;/span&gt;C.P.&lt;/label&gt;
   &lt;input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx"&gt;
  &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But the validation has not happened. I it think is the way I called the validation on the input but I'm not sure what exactly I should call it or make reference to it.</p>