BeginUmbracoForm: validation for @Html.CheckBoxFor not returning Error Message
Hi to everyone.
I'm having difficult obtaining the ErrorMesage from my class in a Surface Controller Form. Everything works as expected except for the validation message when a required checkbox must be ticked. I've been trying many things, but the result is always the same: No Error Message.
Following is part of my Model:
[Required(ErrorMessage = "L'Oggetto della richiesta è un campo Obbligatorio")]
[Display(Name = "Oggetto")]
public string Oggetto { get; set; }
[Required(ErrorMessage = "La Descrizione della richiesta è un campo Obbligatorio")]
[Display(Name = "Descrizione")]
public string Descrizione { get; set; }
//[Required(ErrorMessage = "È necessario confermare di aver letto l'informativa sulla privacy.")]
//[Range(typeof(bool), "false", "true", ErrorMessage = "È necessario confermare di aver letto")] // funziona a rovescio
[Range(typeof(bool), "true", "true", ErrorMessage = "È necessario confermare di aver letto l'informativa!")]
[Display(Name = "Informativa sulla Privacy")]
public bool Privacy { get; set; }
As you can see I have tried also with the [Required] attribute.
BeginUmbracoForm: validation for @Html.CheckBoxFor not returning Error Message
Hi to everyone. I'm having difficult obtaining the ErrorMesage from my class in a Surface Controller Form. Everything works as expected except for the validation message when a required checkbox must be ticked. I've been trying many things, but the result is always the same: No Error Message.
Following is part of my Model:
As you can see I have tried also with the [Required] attribute.
Following is the View fragment:
the view fragment is wrapped inside a using (Html.BeginUmbracoForm("Submit", "FormContatti"))
When I submit with missing fields I get back to the view with all error messages displayed except for the checkbox that has to by ticked:
Anyone can help? Thanks René
Found a solution in an old Stack Overflow post:
MVC Model require true
In case anyone has the same problem
is working on a reply...