Solution for Empty Cart Issue While Checkout in Magento 2
Facing an error while you try to check out from the Magento cart page?
Below is the mentioned code to solve the error with ease. Also provided the guest email address checkout validations.
Email Validation: Enable the 'CONTINUE AS GUEST' button when a valid email address format is provided in the email input field.
email.html
email.js
checkEmail: function () { var email=$("#customer-email").val(); var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; var chckmail=re.test(email); if(chckmail== true){ document.getElementById("guest-to-nextstep").disabled = false; document.getElementById("guest-to-nextstep").style.pointerEvents = "inherit"; } if(chckmail== false){ //alert(1); document.getElementById("guest-to-nextstep").style.pointerEvents = "none"; } }
You can apply the code in Magento development. Please share your review in the comment section.
Comments