Monday, 18 April 2016

how to display server side error message in client side using jquery & MVC

@using (Html.BeginForm("Post", "VendorPortal", FormMethod.Post, new { @id = "frmAddContact" }))



{
<ul>
<li>

  @Html.TextBoxFor(model => model.StreetAddress1, new { @class = "form-control", @required = "required" })
</li>
<li>


<input type="button" class="btn btn-submit" id="btnSubmit" value="Save">


</li>


<li>


<input type="button" id="btnc" class="btn btn-cancel" value="Cancel">


</li>


</ul>
}


<script type="text/javascript">


$(function () {

$('#btnSubmit').click(function () {


$('#frmAddContact').trigger("reset");

$('.field-validation-error').empty();

$('.field-validation-valid').empty();

if ($("#frmAddContact").valid()) {

$("#frmAddContact").submit();






}





});
</script>

No comments:

Post a Comment