Problem:
I have a message A critical error has occurred on this site.
Solution:
Upon further review and by enabling the debug mode I was able to see that the issue was coming from a different plugin.
I advised the customer and shared the logs.
Problem:
Customer would like to set a minimum character limit on the search box - so for example you have to enter at least 10 characters before the search will work. Solution:
To implement the feature of disabling the submit button until there are more than 10 characters in the search box, please add and customize the following JavaScript code in your CRED form's JS box:
jQuery(document).ready(function($) {
// Reference to the search field and submit button
var $searchField = $('input[name="wpv_post_search"]');
var $submitButton = $('input[name="wpv_filter_submit"]');
// Initially disable the submit button
$submitButton.prop('disabled', true);
// Event handler for keyup on the search field
$searchField.on('keyup', function() {
var minLength = 10;
var currentLength = $(this).val().length;
// Enable or disable the submit button based on the character count
if(currentLength >= minLength) {
$submitButton.prop('disabled', false);
} else {
$submitButton.prop('disabled', true);
}
});
});
In the code above:
- The search field is referenced by its name, wpv_post_search.
- The submit button is referenced by its name, wpv_filter_submit.
- The script initially disables the submit button.
- It enables the button only when the character count in the search field is 10 or more.