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 need to add a custom class to a forms field if validation fails.
This post is exactly what I need but it does not work - https://our.umbraco.com/forum/umbraco-forms/90433-umbracoforms-themes-set-error-class-on-wrapper
CMS: 8.14.4 Forms: 8.7.6
@functions { public bool HasErrors(string fieldId) { if (ViewData.ModelState.ContainsKey(fieldId)) { return ViewData.ModelState[fieldId].Errors.Any(); } else { return false; } } public string ValidStateClass(string fieldId) { var klass = ""; if (HasErrors(fieldId)) { klass = "invalid"; } return klass; }
}
@ValidStateClass(f.Id)
Does anyone know how to fix or have an alternative solution?
Thanks
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Forms validation check / helper
I need to add a custom class to a forms field if validation fails.
This post is exactly what I need but it does not work - https://our.umbraco.com/forum/umbraco-forms/90433-umbracoforms-themes-set-error-class-on-wrapper
CMS: 8.14.4 Forms: 8.7.6
}
Does anyone know how to fix or have an alternative solution?
Thanks
is working on a reply...