Conditionally 'Required' fields – How to? JS solution needed

Home Forums Quform WordPress Conditionally 'Required' fields – How to? JS solution needed

This topic is: not resolved

This topic contains 2 replies, has 2 voices, and was last updated by  Ally 1 week, 2 days ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #24963

    katw
    Participant

    I have a field that is only mandatory if a specific checkbox has been checked.

    This field is always visible and should remain so; therefore a conditional logic using show/hide field will not suit.

    The user can fill this field in optionally (ie not required) in most situations BUT if they select a specific checkbox this field becomes mandatory.

    Question:

    Is there a way to programatically toggle or set the ‘required’ state for fields for submit form validation?

    I need to do this in client-side JS.

    #25003

    katw
    Participant

    I see you add a ‘required’ CSS class to fields and don’t use ‘REQUIRED’ parameter on form fields.

    Given this,

    If I set the field as required in the settings and set it up as if it is always expected (ie set validators and error message text)

    Then programatically remove the ‘required’ class… when it is not mandatory…

    Will QuForm ‘On submit’ ignore the required settings and allow the form to go?

    If so I have a solution I could use.

    Please advise if above would work.. or provide a solution if possible.

    #25006

    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.