Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 3 years ago.
Improve this questionI'm building a custom checkout, that uses steps, like those used on Apple.
.jpg
When an input field is marked as invalid, I would like the affected sections to expand again. I can't seem to get the function running on click though.
The test code is very basic. Any why this would not be working? It does work if I change the .click to use the body element, for example.
jQuery('#place_order').click(function(){
if(jQuery('p#billing_last_name_field').hasClass('woocommerce-invalid')) {
alert('INVALID');
} else {
alert('VALID');
}
});
Closed. This question is off-topic. It is not currently accepting answers.
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 3 years ago.
Improve this questionI'm building a custom checkout, that uses steps, like those used on Apple.
http://www.formisimo/blog/wp-content/uploads/2013/09/Apple-stage-one.jpg
When an input field is marked as invalid, I would like the affected sections to expand again. I can't seem to get the function running on click though.
The test code is very basic. Any why this would not be working? It does work if I change the .click to use the body element, for example.
jQuery('#place_order').click(function(){
if(jQuery('p#billing_last_name_field').hasClass('woocommerce-invalid')) {
alert('INVALID');
} else {
alert('VALID');
}
});
As it was already noted by @mmm, your click event is placed too soon. Try with a submit trigger, as suggested in a similar StackOverflow answer:
jQuery(document).ready(function($) {
jQuery("form.woocommerce-checkout").on('submit', function() {
... your code here ...
});
});
('#place_order').click
is too soon, the validation is made later. try the trigger$(document.body).on("update_checkout", ...
– mmm Commented Sep 5, 2015 at 18:42