Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 14th, 2012  |  syntax: None  |  size: 3.01 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <script type="text/javascript" charset="utf-8">
  2.         $(function() {
  3.                 $('#entryform').submit(function() {
  4.                         validate_matrix_dropdown = function(field_id, validate_string) {
  5.                                 $('select[name^='+field_id+']').each(function() {
  6.                                         var blocks = $(this).attr('name').split('[');
  7.                                         var row_id = blocks[1].slice(0, -1);
  8.                                         if($(this).children(':selected').val() == validate_string) {
  9.                                                 $("textarea[name*='"+field_id+"["+row_id+"]']").each(function() {
  10.                                                         if($(this).val() == '') {
  11.                                                                 alert('Please describe.')
  12.                                                                 return false;
  13.                                                         }
  14.                                                 });
  15.                                         }
  16.                                 });
  17.                                
  18.                                 return true;
  19.                         }
  20.                        
  21.                         if(!validate_matrix_dropdown('field_id_105', 'Other - please describe')) { return false; }
  22.                         if(!validate_matrix_dropdown('field_id_137', 'Other')) { return false; }
  23.  
  24.                         var from_bits = $('input[name=field_id_36]').val();
  25.                         var to_bits = $('input[name=field_id_37]').val();
  26.                         if(from_bits == '') { return true;}
  27.                         from_bits = from_bits.split('/');
  28.                         to_bits = to_bits.split('/');
  29.                         var from_date = new Date(parseInt(from_bits[2]), parseInt(from_bits[1]) - 1, parseInt(from_bits[0]));
  30.                         if(to_bits != '') { var to_date = new Date(parseInt(to_bits[2]), parseInt(to_bits[1]) - 1, parseInt(to_bits[0]));       }
  31.                         else { var to_date = new Date(); }
  32.                         var difference_in_weeks = Math.ceil((to_date.getTime() - from_date.getTime()) / (1000 * 60 * 60 * 24 * 7));
  33.                         $('#field_id_39').val(difference_in_weeks);
  34.                        
  35.                        
  36.                         if($('#field_id_343').val() == "") {
  37.                                 if($('#field_id_34').val() == '') { alert("You need to enter the 'Games Ambassador Forename'"); return false; }
  38.                                 if($('#field_id_35').val() == '') { alert("You need to enter the 'Games Ambassador Surname'"); return false; }
  39.                                 if($('#field_id_125').val() == '') { alert("You need to enter the ambassador's 'Age Range'"); return false; }
  40.                                 if($('#field_id_99').val() == '') { alert("You need to enter the ambassador's 'Gender''"); return false; }
  41.                                 if($('#field_id_36').val() == '') { alert("You need to enter the 'Games Ambassador Start Date'"); return false; }
  42.                                 if($('#field_id_101').val() == '') { alert("You need to enter the 'Games Ambassador background'"); return false; }
  43.                                 if($('#field_id_102').val() == '') { alert("You need to enter the 'Games Ambassador Interests'"); return false; }
  44.                                 if($('#field_id_103').val() == '') { alert("You need to enter the 'Games Ambassador Aims/Ambitions/Goals'"); return false; }
  45.                                 $('#field_id_343').val('Current');
  46.                         } else if($('#field_id_343') == 'Current') {
  47.                                 if($('#field_id_37').val() == '') { alert("You need to enter the 'Games Ambassador Leave Date'"); return false; }
  48.                                 if($('#field_id_38').val() == '') { alert("You need to enter the 'Reason for Leaving'"); return false; }
  49.                                 $('#field_id_343').val('Past');
  50.                         }
  51.                                        
  52.                         if($('input[name=field_id_37]').val() != '')
  53.                                 alert('Please now update the Games Ambassador record with evidence of Positive Progressions and Achievements');
  54.                        
  55.                         return true;
  56.                 });
  57.                
  58.                 $('.datepicker').attr('readonly', 'true');
  59.         });
  60. </script>