Forums

Forums / General Discussions / Required Validation on Hidden Fields

Required Validation on Hidden Fields

2 posts, 1 answered
  1. Syed Hammad Aleem
    Syed Hammad Aleem avatar
    5 posts
    Registered:
    25 Nov 2021
    Answered
    07 Dec 2021
    Link to this post
    Hi,

    There is a field 'One' which is by default hidden. It is dependent on another field 'Two'. If users selects 'Two' as yes then 'One' will be shown else it will remain hidden. Field 'One' is a required field. But if it is hidden this requirement should not work but field requirement does not get disable when hidden and the form does not submit as the field is not filled.
    How to disable the field requirement if field gets hidden.
  2. Brady Ward
    Brady Ward avatar
    92 posts
    Registered:
    19 Aug 2021
    07 Dec 2021 in reply to Syed Hammad Aleem
    Link to this post
    Hello Syed,

    Firstly, the field must be client-side enabled. Otherwise, you will not be able to override this functionality.

    Second, there are two ways to accomplish what you're looking for once setting the field to client-side required. You can use the TPC API to either disable the field when hidden and enable it when you show it again or set and remove the requirement as well.

    ie.
    tpc.forms[0].field_developer_name.disable() / tpc.forms[0].field_developer_name.enable()
    tpc.forms[0].field_developer_name.required(true) / tpc.forms[0].field_developer_name.required(false)


    Let me know if you have any further questions on implementing the above.

    Client side API docs: https://www.crmportalconnector.com/developer-network/documentation/portal-connector-widgets/tpc-client-side-api/mvc-based

    All the best,

    Brady
    TPC Web Developer
    Last modified on 07 Dec 2021 14:12 by Brady Ward
2 posts, 1 answered