How to add a onclick attribute to a list of checkboxes?

Store the ID in a variable, and access that variable using JavaScript: <script> document.getElementById(“<?php echo $checkbox_id; ?>”).onclick = function() { chk(electronics, this.checked); } </script> You can also collect multiple IDs in an array and run through that array later in your script. But avoid the onclick attribute in markup, this is bloat and bad code … Read more

Making an input field required from WP’s perspective

I believe yo are looking for wp_die which will Kill WordPress execution and display HTML message with error message. But the codex says: It is not recommended to call this function very often and try to handle as many errors as possible silently.

Contact form with Jquery and PHP don’t work

From your code: $(function() { // Validate the contact form $(‘#contactform’).validate({ WordPress loads jQuery in “no conflict” mode, meaning that the “$” symbol is not defined. Change the “$” to the proper full “jQuery” or use a no conflict wrapper.

How to stop direct HTTP POST to a PHP script?

You must hook the form using wpcf7_before_send_mail and add your PHP code to functions.php (since the script is already in your theme folder)? You won’t lose any of CF7’s abilities. function wpse_process_form( &WPCF7Object ){ #process your form here } add_action(‘wpcf7_before_send_mail’, ‘wpse_process_form’ );