Being able to submit a form and control field visibility at the same time

I want to print errors to the screen within a div and keep them there until there is a successful transmission. However this will not allow a submission. I can submit if I remove the e.preventDefault() but then the content of the error div flashes and vanishes. Is there a way to do both?

 $("#submitButton").click(function (e) 
{
    e.preventDefault();
    $('#message').hide();

 //processing errors

   if (errorstr !== "") {
            var d;
            d = document.getElementById("message");
            d.innerHTML = errorstr;
           $('#message').show();
        }
        else {

            $('#message').hide();
        }
   }


  @using (Html.BeginForm(...)
  {
    <div id="message"></div>
    <input type="submit" name="submitButton" id="submitButton" class="form-input"/>
  }

Answer

Either use ajax or URL.Action to submit the form.

ajax way:

function submitForm()
{
   $.ajax({
      url: 'Controller/Action',
      data: { } // your data
   }).done(function() {
      alert('Success'); 
   });
}

Usage:

if (errorstr !== "") {
            var d;
            d = document.getElementById("message");
            d.innerHTML = errorstr;
           $('#message').show();
        }
        else {
             submitForm();
            $('#message').hide();
        }    }

URL.Action way:

window.location.href = '@Url.Action("Action", "Controller")/' + data;