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

Untitled

By: a guest on May 18th, 2012  |  syntax: None  |  size: 0.84 KB  |  hits: 17  |  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. Weird Firefox Form Submit Event Handling Issue
  2. $loanAppForm.submit(function(event){
  3.         console.log('Can we stop this form submission? ' + (event.cancelable ? 'yes' : 'no'));
  4.  
  5.         var $form = $(this);
  6.         var errors = 0;
  7.  
  8.         $('.required-flag:visible').hide();
  9.  
  10.         $('.required', $form).each(function(){
  11.             var $select = $(this);
  12.             $select.removeClass('error');
  13.  
  14.             if( $select.val() == '' ) {
  15.                 errors++;
  16.                 $select.addClass('error');
  17.                 $select
  18.                     .parents('tr')
  19.                     .children('th')
  20.                     .children('label')
  21.                     .after('<span class="required-flag">required</span>');
  22.             }
  23.         });
  24.  
  25.         console.log('There were ' +errors+ ' errors in your form.');
  26.  
  27.         return ( errors == 0 );
  28.     });