validation input zipcode Mexico zippopotamHow do you disable browser Autocomplete on web form field / input tag?Validate decimal numbers in JavaScript - IsNumeric()How to validate an email address in JavaScriptWhat are valid values for the id attribute in HTML?<button> vs. <input type=“button” />. Which to use?HTML text input allow only numeric inputDisable/enable an input with jQuery?How to send FormData objects with Ajax-requests in jQuery?Cannot display HTML stringParsley : custom validation

First Number to Contain Each Letter

How do I list only modified buffers in vim?

Are language and thought the same?

Is it rude to ask my opponent to resign an online game when they have a lost endgame?

Dissuading my girlfriend from a scam

Did the US Climate Reference Network Show No New Warming Since 2005 in the US?

How do I make my fill-in-the-blank exercise more obvious?

What quests do you need to stop at before you make an enemy of a faction for each faction?

In-universe, why does Doc Brown program the time machine to go to 1955?

What drugs were used in England during the High Middle Ages?

Can I transfer my Australian ETA to my new passport or must I re-apply?

Using processing toolbox conditionally in QGIS?

A magician's sleight of hand

What are some countries where you can be imprisoned for reading or owning a Bible?

How do I stop making people jump at home and at work?

Has Rey's new lightsaber been seen before in canon or legends?

Do mortgage points get applied directly to the principal?

How many people can lift Thor's hammer?

Round away from zero

What's the difference between a share and a stock?

'Hard work never hurt anyone' Why not 'hurts'?

Does blackhole merging breaks their event horizon seggregation?

When making yogurt, why doesn't bad bacteria grow as well?

MOSFET broke after attaching capacitor bank



validation input zipcode Mexico zippopotam


How do you disable browser Autocomplete on web form field / input tag?Validate decimal numbers in JavaScript - IsNumeric()How to validate an email address in JavaScriptWhat are valid values for the id attribute in HTML?<button> vs. <input type=“button” />. Which to use?HTML text input allow only numeric inputDisable/enable an input with jQuery?How to send FormData objects with Ajax-requests in jQuery?Cannot display HTML stringParsley : custom validation






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I need to validate the zip code if is true of Mexico.



I have a form and you can see the code next, I don't understand why don't consider the validation, what is wrong?



I pasted the code of an example I found



http://parsleyjs.org/doc/examples/ajax.html






// 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('');

)

);

//input in form
<div class="consumidor_cp_right">
<div class="consumidor_cp">
<label for="zip"><span>*</span>C.P.</label>
<input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
</div>
</div>





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.










share|improve this question
































    4















    I need to validate the zip code if is true of Mexico.



    I have a form and you can see the code next, I don't understand why don't consider the validation, what is wrong?



    I pasted the code of an example I found



    http://parsleyjs.org/doc/examples/ajax.html






    // 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('');

    )

    );

    //input in form
    <div class="consumidor_cp_right">
    <div class="consumidor_cp">
    <label for="zip"><span>*</span>C.P.</label>
    <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
    </div>
    </div>





    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.










    share|improve this question




























      4












      4








      4








      I need to validate the zip code if is true of Mexico.



      I have a form and you can see the code next, I don't understand why don't consider the validation, what is wrong?



      I pasted the code of an example I found



      http://parsleyjs.org/doc/examples/ajax.html






      // 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('');

      )

      );

      //input in form
      <div class="consumidor_cp_right">
      <div class="consumidor_cp">
      <label for="zip"><span>*</span>C.P.</label>
      <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
      </div>
      </div>





      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.










      share|improve this question
















      I need to validate the zip code if is true of Mexico.



      I have a form and you can see the code next, I don't understand why don't consider the validation, what is wrong?



      I pasted the code of an example I found



      http://parsleyjs.org/doc/examples/ajax.html






      // 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('');

      )

      );

      //input in form
      <div class="consumidor_cp_right">
      <div class="consumidor_cp">
      <label for="zip"><span>*</span>C.P.</label>
      <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
      </div>
      </div>





      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.






      // 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('');

      )

      );

      //input in form
      <div class="consumidor_cp_right">
      <div class="consumidor_cp">
      <label for="zip"><span>*</span>C.P.</label>
      <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
      </div>
      </div>





      // 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('');

      )

      );

      //input in form
      <div class="consumidor_cp_right">
      <div class="consumidor_cp">
      <label for="zip"><span>*</span>C.P.</label>
      <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
      </div>
      </div>






      javascript html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 4:14









      Chipster

      2,2332 gold badges7 silver badges25 bronze badges




      2,2332 gold badges7 silver badges25 bronze badges










      asked Mar 28 at 3:47









      christian torizchristian toriz

      211 bronze badge




      211 bronze badge

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          It worked on my end,



          See the full code below,



          <h1>Custom validators</h1>
          <h3>Simple ajax request</h3>
          <form data-parsley-validate="">
          <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
          <br>
          <input type="submit" value="validate">

          </form>
          <script
          src="http://code.jquery.com/jquery-3.3.1.min.js"
          integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
          crossorigin="anonymous"></script>
          <script src="parsley.min.js"></script>
          <script type="text/javascript">
          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)
          alert(result['places'][0]['state abbreviation']);
          ,
          error: function (result, success)
          alert('Not found');

          )
          ,
          messages: en: 'There is no such zip for the country "%s"'
          );
          Parsley.on('form:submit', function()
          return false; // Don't submit form for this demo
          );
          </script>


          • Test it with zip code 20304, it returns AGU

          • Test it with zip code 90098, it returns nothing and alerts Not
            found


          Check if your parsley js is included and make sure you are not using slim version of jQuery as it doesn't support ajax.






          share|improve this answer


























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389872%2fvalidation-input-zipcode-mexico-zippopotam%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0
















            It worked on my end,



            See the full code below,



            <h1>Custom validators</h1>
            <h3>Simple ajax request</h3>
            <form data-parsley-validate="">
            <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
            <br>
            <input type="submit" value="validate">

            </form>
            <script
            src="http://code.jquery.com/jquery-3.3.1.min.js"
            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
            crossorigin="anonymous"></script>
            <script src="parsley.min.js"></script>
            <script type="text/javascript">
            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)
            alert(result['places'][0]['state abbreviation']);
            ,
            error: function (result, success)
            alert('Not found');

            )
            ,
            messages: en: 'There is no such zip for the country "%s"'
            );
            Parsley.on('form:submit', function()
            return false; // Don't submit form for this demo
            );
            </script>


            • Test it with zip code 20304, it returns AGU

            • Test it with zip code 90098, it returns nothing and alerts Not
              found


            Check if your parsley js is included and make sure you are not using slim version of jQuery as it doesn't support ajax.






            share|improve this answer































              0
















              It worked on my end,



              See the full code below,



              <h1>Custom validators</h1>
              <h3>Simple ajax request</h3>
              <form data-parsley-validate="">
              <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
              <br>
              <input type="submit" value="validate">

              </form>
              <script
              src="http://code.jquery.com/jquery-3.3.1.min.js"
              integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
              crossorigin="anonymous"></script>
              <script src="parsley.min.js"></script>
              <script type="text/javascript">
              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)
              alert(result['places'][0]['state abbreviation']);
              ,
              error: function (result, success)
              alert('Not found');

              )
              ,
              messages: en: 'There is no such zip for the country "%s"'
              );
              Parsley.on('form:submit', function()
              return false; // Don't submit form for this demo
              );
              </script>


              • Test it with zip code 20304, it returns AGU

              • Test it with zip code 90098, it returns nothing and alerts Not
                found


              Check if your parsley js is included and make sure you are not using slim version of jQuery as it doesn't support ajax.






              share|improve this answer





























                0














                0










                0









                It worked on my end,



                See the full code below,



                <h1>Custom validators</h1>
                <h3>Simple ajax request</h3>
                <form data-parsley-validate="">
                <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
                <br>
                <input type="submit" value="validate">

                </form>
                <script
                src="http://code.jquery.com/jquery-3.3.1.min.js"
                integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
                crossorigin="anonymous"></script>
                <script src="parsley.min.js"></script>
                <script type="text/javascript">
                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)
                alert(result['places'][0]['state abbreviation']);
                ,
                error: function (result, success)
                alert('Not found');

                )
                ,
                messages: en: 'There is no such zip for the country "%s"'
                );
                Parsley.on('form:submit', function()
                return false; // Don't submit form for this demo
                );
                </script>


                • Test it with zip code 20304, it returns AGU

                • Test it with zip code 90098, it returns nothing and alerts Not
                  found


                Check if your parsley js is included and make sure you are not using slim version of jQuery as it doesn't support ajax.






                share|improve this answer















                It worked on my end,



                See the full code below,



                <h1>Custom validators</h1>
                <h3>Simple ajax request</h3>
                <form data-parsley-validate="">
                <input type="text" class="input_control" name="zip" id="cp" data-parsley-length="[5,5]" required="" data-parsley-zip="mx">
                <br>
                <input type="submit" value="validate">

                </form>
                <script
                src="http://code.jquery.com/jquery-3.3.1.min.js"
                integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
                crossorigin="anonymous"></script>
                <script src="parsley.min.js"></script>
                <script type="text/javascript">
                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)
                alert(result['places'][0]['state abbreviation']);
                ,
                error: function (result, success)
                alert('Not found');

                )
                ,
                messages: en: 'There is no such zip for the country "%s"'
                );
                Parsley.on('form:submit', function()
                return false; // Don't submit form for this demo
                );
                </script>


                • Test it with zip code 20304, it returns AGU

                • Test it with zip code 90098, it returns nothing and alerts Not
                  found


                Check if your parsley js is included and make sure you are not using slim version of jQuery as it doesn't support ajax.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 28 at 6:19

























                answered Mar 28 at 5:54









                Shoyeb SheikhShoyeb Sheikh

                1,7281 gold badge2 silver badges13 bronze badges




                1,7281 gold badge2 silver badges13 bronze badges





















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389872%2fvalidation-input-zipcode-mexico-zippopotam%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해