Skip to main content

Validate an input field on form submit.

$("form").submit(function () {
  if ($(":input").val() == "") {
    $('<span class="required">*</span>').prependTo('form').fadeOut(1000, function () {
      $(this).remove();
    });
    return false;
  } else {
    return true;
  }
});