You are viewing limited content. For full access, please sign in.

Question

Question

How To: Skip, Bypass, or Disable required fields validation depending on user choice

asked on October 16, 2018 Show version history

Scenario: A form has required fields. However, if the user presses a button like Reject, we don't want to require the user to fill in junk data, especially if a required field is a File Upload field. 

Goal: Skip validation if the user presses "Reject".

Steps: 

  1.  Disable backend validation on the form in question
    • On the Forms Layout tab, press the gear icon, set Backend validation to "No validation"
    • Save
  2. Add the following jquery
    $(document).ready(function (){
     
    // this binds a click action on the Reject button
      $('input.action-btn.ellipsis.Reject').on('click', function() {
    
        $('input, select').each(function() {    
    	  $(this).removeAttr('required');
        });
      }); 
    }); 
    

Result: When the users clicks the Reject form action, no validation takes place. and the Reject action path is taken in the process model. All other actions, live validation takes place and prevents the action from going through.


I've been trying to work this but didn't find an exact post. Was writing something up to save for myself and figured I'd save it here instead :) Many thanks to @Matthew Tingey for putting me down the right path based on his post https://answers.laserfiche.com/questions/141193/check-validation-before-submit#141201 . 

Forms Version 10.3.1.553

6 0

Answer

SELECTED ANSWER
replied on October 16, 2018 Show version history

Answer included in question.

3 0

Replies

replied on August 14 Show version history

Update for 10.4 - Original doesn't work for Rich Text fields, have to add "div" to the function, as follows:

// If "reject" button is clicked
    $('.Reject').click(function(){
      
      // un-require required fields for reject button
      $('input, select, div').each(function() {    
      	$(this).removeAttr('required');
      });

 

1 0
replied on October 16, 2018

Thanks Carl,

 

Exactly what I was after today!

 

Thanks again,

Ziad

0 0
replied on October 17, 2018

Glad it was useful to others!

2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.