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

Question

Posted to Laserfiche Cloud

Question

Clear a single line form field on submit

asked on August 31, 2022

Hi folks,

Can anyone help me clear a single line form field on submit. I'm useless at jquery. Assuming this field's ID is q1, I've tried...

$(document).ready(function ()
	{
  		//Set select value to nothing
  		$('#q1').val('');
	})

I'm doing this in classic form designer. As a side-note, this q1 field will contain HTML tags. We are using the q1 field to set a Rich Text (id=q2) field's default value, which renders the HTML perfectly. But q1's value is causing the form to break on submit. If I clear q1's values manually, the submit works fine. Hiding the field and ignoring values stops the on-screen validation message, but it still breaks on submit. So I guess the other question to ask Laserfiche staff is, is there some script injection code that runs prior to any user-added javascript? If so, the above solution will still be useless.

0 0

Replies

replied on August 31, 2022 Show version history

If it is ok to clear the field as soon as the form is ready, you can try

$document.ready(function() {
 //Set select value to nothing
 $('#q1 .input').val('');
});

But if that does not solve it, then you will have to do it on the submitted form.  Once the form is summitted, it is changed to Read Only mode and you do not have the same elements as when the form is in Read Write mode.  You must check if the form is in Read Only mode and if it is, then you need to update the elements of the Read Only form.  If your #q1 is a single line field, then something like this should work:

$document.ready(function() {
  if ($('[name=IsLocked]').val() == 'True')
  {
    //Set select value to nothing
    $('#q1 .ro').text('');
  }
});

 

0 0
replied on August 31, 2022

Thanks so much Bert, will give it a try.

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

Sign in to reply to this post.