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

Question

Question

Options to Streamline or Pre-Process Field Validation

asked on July 24, 2017 Show version history

I have a pretty large form that I'm using to consolidate information from multiple sources, present it to the user in a readable format, and then allow a limited number of fields to be edited by the user in order to direct later steps in the process.

My form is working well, but I'd like to know if there are options to streamline the field validation that occurs when the user hits submit.  There are so many fields that this process is taking nearly a minute (and is likely to get worse in the future, because part of my form includes collections which I expect will grow over time).

90%+ of my fields are hidden fields that are populated by earlier forms and workflows, so I do not need those fields reviewed for validation.  Is there an option to have the validation ignore those fields?  I'm currently hiding these fields by assigning them a CSS class to hide them.

Alternately, is there an option to disable the validation at submit and instead manually trigger validation at select points in my form (at which point I could just disable the submit button until my desired validations are complete).

As I mentioned, my form is working well as is, it just isn't as fast as I'd like, so I'm just curious about options to streamline the validation process.

0 0

Answer

SELECTED ANSWER
replied on July 26, 2017

Hi Matthew,

To disable frontend validation on certain fields, you may either use field rule to hide the fields, or add a CSS 'lf-no-validate' class on the input/select/... element with script like this (the field has CSS class novalidate):

$('.novalidate input').addClass('lf-no-validate');

To disable frontend validation for all fields, you can add attribute 'formnovalidate' on the submit button with script like this:

$('input.Submit').attr('formnovalidate', '');

 

2 0

Replies

replied on July 26, 2017

I added the lf-no-validate class to every hidden field.  

Many of these are hidden via a class of hiddenField added to the fields in the Layout screen.  The CSS code for that is:

.hiddenField {display: none!important;}

I added the lf-no-validate class to all of those fields with this Javascript code: 

//Set the hiddenField items to be excluded from field validation
$('.hiddenField input').each(function() { 
  $(this).addClass('lf-no-validate');
});
$('.hiddenField textarea').each(function() { 
  $(this).addClass('lf-no-validate');
});
$('.hiddenField select').each(function() { 
  $(this).addClass('lf-no-validate');
});

That adds the class to every hidden field that started with the hiddenField class - input catches text fields, dates, checkboxes, etc. - textarea catches multi-line text boxes - select catches dropdown fields.

I also have fields that are hidden/shown in my Javascript.  These are hidden/show by adding or removing the hiddenField class throughout my Javascript.  I just made sure that every time I hide a field, I add the lf-no-validate class to its input/select/textarea element as well.  And every time I show a field, I remove the lf-no-validate class from its input/select/textarea element as well.

Now when I click submit, it takes two seconds instead of a minute or more.  Yay!

I have not yet experimented with doing an alternate validation.  My form uses pagination, with tabs, and all fields that need validation are contained in collections on each tab/page - so my idea would be to disable all the tabs initially, and then on each page, complete validation of that page's collection when they click the Next button, if the validation doesn't pass it stays on that page, if it does pass, that page's tab will be enabled and the user will go to the next page.  By disabling all the tabs and enabling them one at a time, the user would be able to go back to tabs they had been at before, but not skip past any tabs that had not been through the validation process.  I may still do this, but for now, my form is running efficiently enough with the other changes, that it isn't necessary.

Thanks again @████████ for your help!

1 0
replied on July 26, 2017

Thank you @████████- that's exactly the kind of info I was looking for.  It'll take me some time to try this out and implement it.  I'll report back my results in a day or two.

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

Sign in to reply to this post.