Posts

Showing posts with the label unobtrusive-validation

ASP.NET MVC jQuery Unobtrusive Validation to compare between two dates

Image
Clash Royale CLAN TAG #URR8PPP ASP.NET MVC jQuery Unobtrusive Validation to compare between two dates I'm trying to validate StartDate and EndDate using System.ComponentModel.DataAnnotations , such that the End Date must not be lesser than the Start Date. In my Model, I have defined the dates as follows: StartDate EndDate System.ComponentModel.DataAnnotations public partial class MyModel { [Required] public DateTime StartDate { get; set; } [Required] public DateTime EndDate { get; set; } } And I have also created a View Model as follows: public class CompareDateVM : IValidatableObject { public MyModel myModel { get; set; } public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) { if (myModel.EndDate < myModel.StartDate) { yield return new ValidationResult(errorMessage: "End Date cannot be lesser than Start Date.", memberNames: new { "EndD...

Error messages of jquery validate plugin is overriding jquery unobtrusive validator plugin

Error messages of jquery validate plugin is overriding jquery unobtrusive validator plugin I have a form (created by Sitecore CMS form builder) that renders the validation error messages in data attributes. The problem is that for some fields, email, for instance, it shows the validation error message from the jquery validates plugin instead of the one specified in data attributes. Here is the form <label for="fxb_00000000-0000-0000-0000-000000000000_Fields_3ea0670b-4aa8-43cf-af7a-3c4c18e2c8c2__Value" class="placeholder">Email*</label> <input id="fxb_00000000-0000-0000-0000-000000000000_Fields_3ea0670b-4aa8-43cf-af7a-3c4c18e2c8c2__Value" name="fxb.00000000-0000-0000-0000-000000000000.Fields[3ea0670b-4aa8-43cf-af7a-3c4c18e2c8c2].Value" class="form-holder__item input-validation-error" type="email" value="" maxlength="255" placeholder="Email*" data-sc-tracking="True" data-sc-...