1$(document).ready(function(){ 2 3 $("#registerEventGroup select[name='groupnr']").change(function() 4 { 5 var number = $(this).val(); 6 var group = $("#groupList"); 7 var children = group.children().length; 8 9 if(number > children) { 10 // Append children 11 for(var i = children; i < number; i++) { 12 var shtml = '<div id="person' + i + '"><div class="form-check">\ 13 <div class="custom-control custom-checkbox custom-control-inline">\ 14 <input type="radio" class="custom-control-input" name="groupSignUp' + i + '" value="medlem" id="checkRegister1" checked>\ 15 <label class="custom-control-label" for="checkRegister1' + i + '">Medlem</label>\ 16 </div>\ 17 <div class="custom-control custom-checkbox custom-control-inline">\ 18 <input type="radio" class="custom-control-input" name="groupSignUp' + i + '" value="ikke" id="checkRegister2">\ 19 <label class="custom-control-label" for="checkRegister2' + i + '">Ikke medlem</label>\ 20 </div>\ 21 <div class="custom-control custom-checkbox custom-control-inline">\ 22 <input type="radio" class="custom-control-input" name="groupSignUp' + i + '" value="meldInn" id="checkRegister3">\ 23 <label class="custom-control-label" for="checkRegister3' + i + '">Ikke medlem, meld inn</label>\ 24 </div>\ 25 </div>\ 26\ 27 <div class="form-group">\ 28 <label for="REJs-1">Fornavn</label>\ 29 <input type="text" maxlength="50" class="form-control" id="REJs-1" name="personName' + i + '" required>\ 30 </div>\ 31 \ 32 <div class="form-group">\ 33 <label for="REJs-2">Etternavn</label>\ 34 <input type="text" maxlength="50" class="form-control" id="REJs-2" name="personLastname' + i + '" required>\ 35 </div>\ 36 \ 37 <div id="groupSignUp' + i + '">\ 38 <div class="form-group">\ 39 <label for="REJs-3">Privatadresse</label>\ 40 <input type="text" maxlength="50" class="form-control" id="REJs-3" name="personAddress' + i + '">\ 41 </div>\ 42 \ 43 <div class="form-group row">\ 44 <div class="col-md-4">\ 45 <label for="REJs-4">Postnummer</label>\ 46 <input type="text" maxlength="50" class="form-control" id="REJs-4" name="personPostnumber' + i + '">\ 47 </div>\ 48 \ 49 <div class="col-md-8">\ 50 <label for="REJs-5">Sted</label>\ 51 <input type="text" maxlength="50" class="form-control" id="REJs-5" name="personCity' + i + '">\ 52 </div>\ 53 </div>\ 54 </div>\ 55 \ 56 <div class="form-group">\ 57 <label for="REJs-6">E-post</label>\ 58 <input type="email" maxlength="150" class="form-control" id="REJs-6" name="personEmail' + i + '" required>\ 59 </div>\ 60 \ 61 <div class="form-group">\ 62 <label for="REJs-7">Mobil</label>\ 63 <input type="text" maxlength="50" class="form-control" id="REJs-7" name="personMobile' + i + '" required>\ 64 </div><hr></div>'; 65 66 var child = group.append(shtml); 67 $("#groupSignUp" + i).hide(); 68 var radios = document.querySelectorAll("input[name='groupSignUp" + i + "']"); 69 for(var j = 0; j < radios.length; j++) { 70 radios[j].addEventListener('click', function() { 71 var name = $(this).attr('name'); 72 if( $(this).attr( 'value' ) == 'meldInn' ){
73 $('#' + name + 'input').prop("required", true); 74 $('#' + name).show(); 75 } 76 else{ 77 $('#' + name + 'input').prop("required", false); 78 $('#' + name).hide(); 79 } 80 }); 81 } 82 } 83 } 84 85 if(number < children) { 86 // Remove children 87 for(var i = children; i > number; i--) { 88 var child = group.children().length; 89 jQuery("#person" + (child - 1)).remove(); 90 } 91 } 92 }); 93 94 $( "#successMessageFormEvent").hide(); 95 $( "#failMessageFormEvent").hide(); 96 97 $("span.requiredField").hide(); 98 $("span.privatField").hide(); 99 $("#invoiceAlert").hide(); 100 101 $('#registerEventGroup').on('submit', function(e) 102 { 103 e.preventDefault(); 104 105 var formData = $(this).serialize(); 106 var dataOK = true; 107 var serviceUrl = $("#registerEventGroup input[name='registerServiceGroup']").val(); 108 var fieldMissing = 'Felt mangler'; 109 110 $("span.requiredField").each(function(idx, it){ 111 if( ($(it).parent().find("select").val() == "") || ($(it).parent().find("input").val() == "") ) 112 { 113 dataOK = false; 114 $(it).show(); 115 $("#failMessageFormEvent").text( 'Følgende felt mangler.' ); 116 $("#failMessageFormEvent").show(); 117 } else { 118 $(it).hide(); 119 $("#failMessageFormEvent").hide(); 120 } 121 }); 122 123 var signUpMedlem = $(this).find("input[name='signUpForm']").val(); 124 signUpMedlem = signUpMedlem && (signUpMedlem == "true"); 125 126 var er_i_jobb = $(this).find("select[name='medlemstype']").val(); 127 128 var signUpEvent = $(this).find("input[name='signUpEvent']").val(); 129 signUpEvent = signUpEvent && (signUpEvent == "true"); 130 131 // Allow students and Arbeidsledig whitout check radio button 132 var invoiceSelected = ($("input[name='invoiceOption']").length > 0) ? $(this).find("input[name='invoiceOption']:checked").val() : 'none'; 133 if( ( (signUpMedlem && (er_i_jobb == "Er i jobb" || er_i_jobb == "") ) || (signUpEvent) ) && (invoiceSelected == undefined) ) 134 { 135 dataOK = false; 136 $("#invoiceAlert").show(); 137 $("#failMessageFormEvent").text( 'Følgende felt mangler.' ); 138 $("#failMessageFormEvent").show(); 139 } else { 140 $("#invoiceAlert").hide(); 141 $("#failMessageFormEvent").hide(); 142 } 143 144 if( ( (signUpMedlem && (er_i_jobb == "Er i jobb") ) || (signUpEvent) ) && (invoiceSelected == "invoice_send_private") ) 145 { 146 var address = $(this).find("input[name='address']").val() || ""; 147 var postnumber = $(this).find("input[name='postnumber']").val() || ""; 148 var city = $(this).find("input[name='city']").val() || ""; 149 150 if( address == "" ) 151 { 152 dataOK = false; 153 $("input[name='address']").parent().find("span.privatField").show(); 154 } else { 155 $("input[name='address']").parent().find("span.privatField").hide(); 156 } 157 if( postnumber == "" ) 158 { 159 dataOK = false; 160 $("input[name='postnumber']").parent().find("span.privatField").show(); 161 } else { 162 $("input[name='postnumber']").parent().find("span.privatField").hide(); 163 } 164 if( city == "" ) 165 { 166 dataOK = false; 167 $("input[name='city']").parent().find("span.privatField").show(); 168 } else { 169 $("input[name='city']").parent().find("span.privatField").hide(); 170 } 171 if( !dataOK ) 172 { 173 $("#failMessageFormEvent").text( 'Følgende felt mangler.' ); 174 $("#failMessageFormEvent").show(); 175 } 176 177 } else { 178 $("input[name='address']").parent().find("span.privatField").hide(); 179 $("input[name='postnumber']").parent().find("span.privatField").hide(); 180 $("input[name='city']").parent().find("span.privatField").hide(); 181 } 182 183 if ( $("#registerEvent select[name='medlemstype']").val() == "Er i jobb" || $("#registerEvent select[name='medlemstype']").val() == "Arbeidssøkende" ) 184 { 185 $("span.privatField").each(function(idx, it){ 186 if( ($(it).parent().find("select").val() == "") || ($(it).parent().find("input").val() == "") ) 187 { 188 dataOK = false;
189 $(it).show(); 190 $("#failMessageFormEvent").text( 'Følgende felt mangler.' ); 191 $("#failMessageFormEvent").show(); 192 } else { 193 $(it).hide(); 194 $("#failMessageFormEvent").hide(); 195 } 196 }); 197 } 198 else 199 { 200 $("span.privatFieldStudent").each(function(idx, it) 201 { 202 if( ($(it).parent().find("select").val() == "") || ($(it).parent().find("input").val() == "")) 203 { 204 dataOK = false; 205 $(it).show(); 206 $("#failMessageFormEvent").text( 'Følgende felt mangler.' ); 207 $("#failMessageFormEvent").show(); 208 } 209 else 210 { 211 $(it).hide(); 212 $("#failMessageFormEvent").hide(); 213 } 214 }); 215 } 216 217 if( dataOK ) 218 { 219 $.ajax({ 220 url: serviceUrl, 221 method: 'POST', 222 dataType: 'json', 223 data: formData, 224 success: function(data) 225 { 226 if (data.statusMessage == "success") { 227 228 //window.location.replace(redirectAfterLogin); 229 $("#btn-confirmation-box").click(); 230 //$("#successMessageFormEvent").show(); 231 $("#failMessageFormEvent").hide(); 232 $("#invoiceAlert").hide(); 233 //$('#registerEvent').trigger("reset"); 234 235 $("#modalOk").click( function() { 236 var redirectPage = data.linkRedirect; 237 if( redirectPage ) { 238 window.location.replace( redirectPage ); 239 } else { 240 window.location.reload(); 241 $(document).scrollTop(0); 242 } 243 }); 244 } 245 246 if (data.statusMessage == "fail") 247 { 248 //window.location.replace(redirectAfterLogin); 249 $("#btn-failure-box").click(); 250 //$("#successMessageFormEvent").show(); 251 $("#failMessageFormEvent").hide(); 252 $("#invoiceAlert").hide(); 253 //$('#registerEvent').trigger("reset"); 254 255 $("#modalFailureOk").click( function() { 256 var redirectPage = data.linkRedirect; 257 if( redirectPage ) { 258 window.location.replace( redirectPage ); 259 } else { 260 window.location.reload(); 261 $(document).scrollTop(0); 262 } 263 }); 264 $("#successMessageFormEvent").hide(); 265 } 266 }, 267 error: function(xhr, status, error) 268 { 269 //window.location.replace(redirectAfterLogin); 270 $("#btn-failure-box").click(); 271 //$("#successMessageFormEvent").show(); 272 $("#failMessageFormEvent").hide(); 273 $("#invoiceAlert").hide(); 274 //$('#registerEvent').trigger("reset"); 275 276 $("#modalFailureOk").click( function() { 277 var redirectPage = data.linkRedirect; 278 if( redirectPage ) { 279 window.location.replace( redirectPage ); 280 } else { 281 window.location.reload(); 282 $(document).scrollTop(0); 283 } 284 }); 285 286 $("#successMessageFormEvent").hide(); 287 } 288 }); 289 } else { 290 $("#successMessageFormEvent").hide(); 291 $("#failMessageFormEvent").text(fieldMissing); 292 $("#failMessageFormEvent").show(); 293 } 294 }); 295});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.