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;
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.
javascript html
add a comment |
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.
javascript html
add a comment |
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.
javascript html
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
javascript html
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
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
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
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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