I would like to know how to detect postcode change on cart page.
This code won't work.
$(".input-text[name=postcode]").on("change", function(){ console.log('detected'); });
Hello,
Magento 2 using KO for a quote so you can easily get current shipping postcode easily from js
require(['jquery','Magento_Checkout/js/model/quote'], function($,quote){ console.log(quote.shippingAddress().postcode) })
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"
I'm sorry but my question was how to detect When the postcode is changed.
Also the code is getting an error.
Uncaught TypeError: Cannot read property 'postcode' of null
Try with below code in js and let me know,
$( document ).on( "change",'input[name="postcode"]', function() { console.log(getPostcode()); });