Skip to content

Instantly share code, notes, and snippets.

@Maarten88
Last active December 17, 2015 06:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Maarten88/5563693 to your computer and use it in GitHub Desktop.
Save Maarten88/5563693 to your computer and use it in GitHub Desktop.
<div class="control-group error">
<label class="control-label" for="Title">Title</label>
<div class="controls">
<input class="input-block-level" data-val="true" data-val-required="Dit is een verplicht veld." id="Title" name="Title" type="text" value="Test Veiling">
<span class="help-inline field-validation-error" data-valmsg-for="Title" data-valmsg-replace="true">
<span for="Title" generated="true" class="" style="">Dit is een verplicht veld.</span>
</span>
</div>
</div>
<div class="control-group error">
<label class="control-label" for="Title">Title</label>
<div class="controls">
<input class="input-validation-error input-block-level" data-val="true" data-val-required="Dit is een verplicht veld." id="Title" name="Title" type="text" value="">
<span class="field-validation-error help-inline" data-valmsg-for="Title" data-valmsg-replace="true">Dit is een verplicht veld.</span>
</div>
</div>
@Html.EditorFor(model => model.Title)
@using Auction.Web.Utility
@model object
@{
var htmlAttributes = new RouteValueDictionary();
if (ViewBag.@class != null)
{
htmlAttributes.Add("class", ViewBag.@class);
}
if (ViewBag.@type != null)
{
htmlAttributes.Add("type", ViewBag.@type);
}
if (ViewBag.placeholder != null)
{
htmlAttributes.Add("placeholder", ViewBag.placeholder);
}
}
<div class="control-group@(Html.ValidationErrorFor(m => m, " error"))">
@Html.LabelFor(m => m, new { @class = "control-label" })
<div class="controls">
@Html.TextBox(
"",
ViewData.TemplateInfo.FormattedModelValue,
htmlAttributes)
@Html.ValidationMessageFor(m => m, null, new { @class = "help-inline" })
</div>
</div>
$.validator.setDefaults({
highlight: function (element) {
$(element).closest(".control-group").addClass("error");
},
unhighlight: function (element) {
$(element).closest(".control-group").removeClass("error");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment