How do I get dataanotation to talk to a custom jquery script.
public class ProductViewModel
{
[Required]
public string Name { get; set; }
}
@using (Html.BeginForm)
{
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model=>Model.Name)
<input type="submit" value="Submit" id="NewVarianceSubmitButton" />
}
Now jquery
$(":submit").click(function () {
if dataannotations are all valid above then ...BUT HOW!
$(this).clone().insertAfter($(this)).attr("disabled", "true");
$(this).hide();
You need to enable client side validation.
You would not write code to enable or disable. It is all done for you by using client-side calidation enabled.