Form submitting despite validation LINQtoSQL
I am using Linq to SQL data annotation validations. I get the validation
messages if some fields are invalid. However if I hit save, the form still
submits (with the invalid values).
<input type="button" id="btnSave" name="submit" value="Save" />
$("#btnSave").on("click", saveRecord);
function saveRecord() {
//document.forms[0].submit();
$.ajax(
{ type: 'Post' ,
url: '@Url.Action("Save", "Orders")',
data: {
OrderID: '@Model.OrderID',
ShipName: $('.Name input').val(),
ShipAddress: '@Model.ShipAddress',
RequiredDate: '@Model.RequiredDate',
ShipPostalCode: '@Model.ShipPostalCode'
},
dataType: "html",
success: function (data){
//alert ('saved');
}
})
return false;
}
No comments:
Post a Comment