jQuery(document).ready(function ($) {
			// Initialize Select2
			jQuery('.order-status-selection').select2();
		
			// Disable the button initially if the input is empty
			checkInputAndDisableButton();

			// Add an event listener to check the input on keyup
			jQuery('#buffer_time').on('keyup', function() {
				checkInputAndDisableButton();
			});
			jQuery('#elex_mv_date_of_month_pay_settle').on('keyup', function() {
				checkInputAndDisableButton();
			});
			jQuery('#elex_mv_order_status_radios').on('change',function(){
				checkInputAndDisableButton();
			});	
	   
	});
		function checkInputAndDisableButton() {
			// Get the value of the input field
			var inputdate = jQuery('#elex_mv_date_of_month_pay_settle').val();
			var status = jQuery('#elex_mv_order_status_radios').val().length;
			// Check if the input is empty
			if ( inputdate === '' || status === 0) {
				// If empty, disable the button
				jQuery('#submit').prop('disabled', true);
			} else {
				// If not empty, enable the button
				jQuery('#submit').prop('disabled', false);
			}
		}
		validation_for_forms_func('#elex_mv_date_of_month_pay_settle', /^(2[0-8]|1[0-9]|[1-9])$/,'#elex_mv_date_of_month_pay_settle-error', 'Enter a date between 1 and 28');
		validation_for_forms_func_select('#elex_mv_order_status_radios', /^.+$/,'#elex_mv_order_status_radios-error', 'Select atleast one order status');

		function validation_for_forms_func(id_for_input_element, regex_for_string, id_for_error_element, error_string){
			jQuery(id_for_input_element).keyup(function(){
			const regex = regex_for_string;

			if(! regex.test(this.value)){
				jQuery(id_for_error_element).html(`<div class="text-danger">${error_string}</div>`);
			}else{
				jQuery(id_for_error_element).html('');

			}
			});
		}
		function validation_for_forms_func_select(id_for_input_element, regex_for_string, id_for_error_element, error_string){
			jQuery(id_for_input_element).on('change',function(){
			const regex = regex_for_string;
			if(! regex.test(this.value)){
				jQuery(id_for_error_element).html(`<div class="text-danger">${error_string}</div>`);
			}else{
				jQuery(id_for_error_element).html('');

			}
			});
		}
