Thursday, December 1, 2011

prevent a form from submitting with jQuery

(function () {

   $('form').submit(function (e) {

      var atLeastOneException = false;

      if ($('#myField').val() == '') {

         atLeastOneException = true;

      }

      if (atLeastOneException) {

         e.preventDefault();

         $('#myButton').addClass('ui-state-disabled');

      }

   });

})();

No comments:

Post a Comment