i am tring to load some jquery code to make validation in the theme customizer. i have created 10 checkboxes to show some info. but i want to limited the user to choose only 5 checkboxes. so i have created jquery code to do so, and this code works fine when i put this code in the chrome console.
jQuery(document).ready(function($){
$("#section id input[type=checkbox]").click(function(){
var countchecked = $("#section id input[type=checkbox]:checked").length;
if(countchecked >= 2)
{
$('#section id input[type=checkbox]').not(':checked').attr("disabled",true);
}
else
{
$('#section id input[type=checkbox]').not(':checked').attr("disabled",false);
}
});
});
what i have missed? which codec i need to use to insert in functions.php that will load some jquery code when the user using customize.php (theme customizer)?
i want to make all the validation before user trying to save all the changes.
thanks for help.
Create a
/js
subfolder in your theme directory, if such does not exist already.Save your script to a file in said folder.
Then, in functions.php:
Related Resources:
admin_enquque_scripts
hookwp_enquque_script
function