Berikut contoh penggunaan remove validation pada model di ASP MVC. Remove validation hanya berfungsi jika fungsi client side validation diaktifkan.
[code language=”csharp”]
[Remote("CheckForUniqueEmail", "Membership", "SecurityGuard", AdditionalFields="User.UserName", ErrorMessage = "This {0} is already used.")]
public string Email { get; set; }
[/code]
[code language=”html”]
<div class="form-group">
@Html.LabelFor(model => model.Email, new { @class = "col-xs-2 control-label" })
<div class="col-xs-4">
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Email)
</div>
</div>
[/code]
Cara mengaktifkan client side validation
[code language=”html”]
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
[/code]