Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rick 36 posts 150 karma points
    Nov 30, 2017 @ 14:52
    Rick
    0

    Custom Validation Frustration

    Hi All,

    I'm working with Umbraco 7.6.5 and have the non-licensed version of Forms v6.0.3 installed to do a proof-of-concept requirement for a customer and have hit a brick wall trying to implement custom validation.

    Overview: The customer needs to be able implement customized validation against e-mail addresses depending on what the site visitor is trying to do. In one case, the registration is being validated as "non-personal" e-mail addresses where domains such as gmail and yahoo are not allowed. In the other, the visitor must be a known partner domain.

    This can fairly easily be achieved when making a form manually and using jQuery validate, but the customer wants the features of Forms where the form information is available through the Umbraco admin interface as well as the workflow functionality.

    Additionally, the code for the validation needs to be able to be managed solely through the Umbraco admin interface (e.g. - using Visual Studio or similar IDE is not an option).

    First Roadblock: I am not able to add a custom option in the validation dropdown. I followed the information in this post, but got nothing: https://our.umbraco.org/forum/umbraco-forms/85812-how-to-a-custom-validation-on-a-field-type-in-umbraco-form.

    Second Roadbloack: I cannot find any full working example on how to implement custom validation directly in a Partial View. I've seen several posts similar to this: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73152-umbraco-forms-custom-validation but this is presenting its own problems. In the past, I've implemented custom functions using the @functions {} block as used in packages such as the Cultiv Razor Contact Form but I get nothing but errors when trying this.

    Third Roadblock: I cannot find any documentation on how to get fields and field values even if I can get past the 2nd roadblock. I see things like @ConstantNames and Caption but nothing on what these are. Is the Caption the alias (ex: firstName) or the label (ex: "First Name")?

    If I fallback to using client side validation leveraging jQuery validate, is there really no way to set the name or id property using Forms? Is my only option to use the GUIDs which I can only see when I publish the form to a page and use the inspector?

    I've also tried this in a @functions {} section in a Partial View, but the ApplicationStarted constructor throws errors: https://www.snip2code.com/Snippet/817170/Umbraco-Forms-validation-example.

    If anyone can provide any comprehensive example / link, I would greatly appreciate it.

    Thank you in advance, ~Frustrated~

Please Sign in or register to post replies

Write your reply to:

Draft