×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Matt Parry
Added: May 2, 2017 7:35 PM
Views: 2340
Tags: jquery
  1.         $('#the_contact_us_button').click(function (e) {
  2.             e.preventDefault();
  3.             var form = $(this).closest('form');
  4.  
  5.             $('#repair_errors').text('');
  6.             var noErrors = true;
  7.             $('[required="required"]').each(function (index) {
  8.                 if ($(this).val() == '') {
  9.                     noErrors = false;
  10.                     $(this).css('background-color', 'rgba(255, 0, 0, 0.1)');
  11.                     $('#repair_errors').text('Please fill out all fields. Fields marked red are required.');
  12.                 }
  13.             });
  14.  
  15.             if (noErrors) {
  16.  
  17.                 //DO THIS
  18.  
  19.             }
  20.             }
  21.