I have a very simple form in MVC 4.0, my project is based off the bootstrap3 for MVC4 VS2012 template. All I wish to do is have the user submit the form, then do some validations in my controller, and then based on what I pass back to the view, it should show a bootstrap alert(either error or success)
I have the form wired up so that it when I click Send it correctly fires the correct action on the controller. But I'm unsure about the following thing:
- How do I hide the alert so it only shows after I return a result to the view.
- I wish to display either an error or success alert, would I do this in jQuery, through .addClass?
![enter image description here][1]
[1]:
<div class="panel panel-info">
<div class="panel-heading"><strong>Register your interest</strong></div>
<p></p>
<div class="panel-body">
<form name="contactform" class="form-inline" role="form" method="post" action="/Home/Contact">
<div class="form-group">
<label class="text-info">Name</label>
<input type="text" class="form-control" placeholder="Name">
</div>
<p></p>
<div class="form-group">
<label class="text-info">Email</label>
<input type="email" class="form-control" placeholder="Email">
</div>
<p></p>
<div class="form-group">
<label class="text-info">Comments</label><br />
<textarea class="form-control" cols="20" rows="2" style="width: 400px; height: 150px; max-height: 350px; max-width: 500px"></textarea>
</div>
<p></p>
<button id="myBtn" type="submit" value="send" class="btn btn-primary">Send</button><p />
<div class="alert alert-success" >
<strong>Thank you!</strong> Your query has been submitted.
</div>
</form>
</div>