I have simple form with get request, but jquery validate unobtrusive does not generate HTML for validation message.
I don't know what is wrong =(
Razor:
<form class="input-form" action="someUrl" method="get">
@Html.ValidationSummary(true)
@for (var i = 0; i < 2; i++)
{
@{
var newId = Guid.NewGuid();
}
@Html.TextBoxFor(m => m.Value, new { @class = "input-item", id = newId })
@Html.ValidationMessageFor(m => m.Value, "message", new { @class = "error", id = newId})
}
<button class="submit-button" type="submit">Submit</button>
</form>
<form class="input-form" action="someUrl" method="get" novalidate="novalidate">
<input class="input-item" id="Value" name="Value" id="fcacdcb4-02fb-4701-8b8a-a0aa1d5799ae" type="text" value="0">
<input class="input-item" id="Value" name="Value" id="590afe32-3266-497d-ad3b-b1f9939540ef" type="text" value="0">
<button class="submit-button" type="submit">Submit</button>
</form>
There are not elements with validation message.
I have this Model in C#:
public class InputViewModel
{
public HtmlString Description { get; set; }
public string Alias { get; set; }
[Required]
public int Value { get; set; }
public string Label { get; set; }
}
}
I also have the necessary scripts in the parent view:
<script src="jquery.js"></script>
<script src="JQuery/jquery.validate.min.js"></script>
<script src="JQuery/jquery.validate.unobtrusive.min.js"></script>
I don't know what I missed.
UPD:
Unfortunately I can not show the production code, but it is almost the same as in the question.
I still can’t understand what I'm doing wrong and why there is no validation div in the result HTML.=(
Can you tell me more options for validating fields on the client?