@@ -84,9 +84,40 @@ <h4>Define the parameters used for protocol {{prot_parameters.protocol_name}}</h
84
84
csvFileName :'protocol_parameters' ,
85
85
minDimensions :[ 6 , 3 ] ,
86
86
} ) ;
87
-
87
+ // Function to check if at least one checkbox in the "Used" column is set to true
88
+ function isAnyUsedColumnChecked ( ) {
89
+ var table_data1 = table1 . getData ( ) ;
90
+ // Assuming the "Used" column is the third column (index 2)
91
+ for ( var i = 0 ; i < table_data1 . length ; i ++ ) {
92
+ if ( table_data1 [ i ] [ 2 ] === true && table_data1 [ i ] [ 0 ] != "" ) { // Check if "Used" column (index 2) is true
93
+ return true ;
94
+ }
95
+ }
96
+ return false ;
97
+ }
98
+ // Function to check if at one checkbox in the "Used" column is set to true
99
+ function orderValueDefined ( ) {
100
+ var table_data1 = table1 . getData ( ) ;
101
+ // Check that if parameter is defined then order is also defined
102
+ for ( var i = 0 ; i < table_data1 . length ; i ++ ) {
103
+ if ( table_data1 [ i ] [ 0 ] != "" && table_data1 [ i ] [ 1 ] == "" ) { // Check if "Order" is set a value
104
+ return false ;
105
+ }
106
+ }
107
+ return true ;
108
+ }
88
109
$ ( document ) . ready ( function ( ) {
89
110
$ ( "#defineProtocolParameters" ) . submit ( function ( e ) {
111
+ if ( ! isAnyUsedColumnChecked ( ) ) {
112
+ e . preventDefault ( ) ; // Prevent form submission
113
+ alert ( 'You must select at least one "Used" checkbox before submitting.' ) ;
114
+ return false ;
115
+ }
116
+ if ( ! orderValueDefined ( ) ) {
117
+ e . preventDefault ( ) ; // Prevent form submission
118
+ alert ( 'You must define the order number for each parameter before submitting.' ) ;
119
+ return false ;
120
+ }
90
121
//stop submitting the form to see the disabled button effect
91
122
//e.preventDefault();
92
123
//disable the submit button
0 commit comments