Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I kwow that this may not be directly related to Umbraco, but I can't seem to get my Unobtrusive validation to work. Do I have to configure something else? Something in the Startup.cs?
Startup.cs
I've added these scripts:
<script src="~/js/jquery-3.5.1.min.js"></script> <script src="~/js/jquery-migrate-3.0.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-ajax-unobtrusive/3.2.6/jquery.unobtrusive-ajax.min.js"></script>
This is my model:
public class ContactFormModel { public const string TempDataKey = "ContactSuccess"; public string PlaceHolderName { get; } = string.Empty; public string PlaceHolderEmail { get; } = string.Empty; public string PlaceHolderSubject { get; } = string.Empty; public string PlaceHolderMessage { get; } = string.Empty; public string ButtonText { get; } = string.Empty; public string SuccesMessage { get; } = string.Empty; public string ErrorMessage { get; } = string.Empty; [Required] public string Name { get; set; } [Required] [EmailAddress] public string Email { get; set; } [Required] [MaxLength(500)] public string Message { get; set; } public ContactFormModel() { } public ContactFormModel(Home home) { PlaceHolderName = home.ContactFormNameLabel; PlaceHolderEmail = home.ContactFormEmailLabel; PlaceHolderMessage = home.ContactFormMessageLabel; ButtonText = home.ContactFormButtonText; SuccesMessage = "Uw mail is verzonden"; ErrorMessage = "Er is iets misgegaan bij het verzenden van uw mail"; } }
And this is my form:
@using(Html.BeginUmbracoForm<HomeController>(nameof(HomeController.SendMail), FormMethod.Post)) { <div class="col-md-12"> <input type="text" asp-for="Name" id="name" placeholder="@Model.PlaceHolderName"> </div> <div class="col-md-12"> <input type="email" asp-for="Email" id="email" placeholder="@Model.PlaceHolderEmail"> </div> <div class="col-md-12"> <textarea asp-for="Message" id="message" cols="40" rows="3" placeholder="@Model.PlaceHolderMessage"></textarea> </div> <div class="col-md-12"> <button class="butn-dark mt-15" type="submit"><a href="#0"><span>@Model.ButtonText</span></a></button> </div> }
What does the rendered form look like, are you seeing your data-val-* attributes?
data-val-*
Hi Greg, thanks for your reply. I do see the data-val-* attributes.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco - Unobtrusive Validation
I kwow that this may not be directly related to Umbraco, but I can't seem to get my Unobtrusive validation to work. Do I have to configure something else? Something in the
Startup.cs
?I've added these scripts:
This is my model:
And this is my form:
What does the rendered form look like, are you seeing your
data-val-*
attributes?Hi Greg, thanks for your reply. I do see the data-val-* attributes.
is working on a reply...