In nopCommerce I want that when I click next btn in shipping address form without selecting country and state I should redirect to page with validation but when I click on next btn it is redirecting to dropdown option.
To solve this I have written below code but it is not working as required.enter image description here[[page when Ienter image description here click next without selecting country and state](https://i.stack.imgur.com/aebiP.png)](https://i.stack.imgur.com/7sR1d.png)
I tried below lines of code using javascript:
window.onload = function () {
if ($(".validation-summary-errors").length > 0) {
// If validation is fired, show the shipping address form and uncheck the pickup in store checkbox
$('#shipping-addresses-form').show();
$("#@Html.IdFor(model => model.PickupInStore)").prop("checked", false);
// Log a message to check if this code is running
console.log("Validation errors detected. Handling dropdown and checkbox.");
// Select the "ship to home address" option in the dropdown
$("#pickup-points-select").val("ship_to_home");
}
}
First I checked whether validation is fired
If above condition is true then shipping address form with Ship_to_home_address option should be selected from dropdown.
But above is not working as expected.