当我发布以下表单时,它会请求服务器。如何阻止它发布到服务器并使用jquery验证在客户端进行验证?
这是我的代码:
<form asp-controller="Gigs" asp-action="Create" method="post">
<div class="form-group">
<label asp-for="@Model.Venue"></label>
<input asp-for="@Model.Venue" class="form-control" />
<span asp-validation-for="@Model.Venue"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Date"></label>
<input asp-for="@Model.Date" class="form-control" />
<span asp-validation-for="@Model.Date"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Time"></label>
<input asp-for="@Model.Time" class="form-control" />
<span asp-validation-for="@Model.Time"></span>
</div>
<div class="form-group">
<label asp-for="@Model.Genre"></label>
<select asp-for="@Model.Genre" asp-items="@(new SelectList(Model.Genres, "Id", "Name"))" class="form-control"><option>Please Select One</option></select>
<span asp-validation-for="@Model.Genre"></span>
</div>
<button type="submit" class="btn btn-primary">Save</button>
</form>
我尝试了这个,但没有工作
<environment names="Development">
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
</environment>