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

Discussion

Discussion

Possibility to set the Comments box as compulsory

posted on April 18, 2017

Hi,

Is it possible to set the Comments box in Laserfiche Forms as a compulsory field as shown below?

Please advise.

 

0 0
replied on April 19, 2017

Thanks a lot, Raul. Indeed, it works perfectly.

0 0
replied on April 19, 2017

Hello Raul,

I am in the same team as Sheila. I tried your code above but the red error message don't hide. As soon as the form loads, it appears. Please advise.

 

Regards,

-Guillaume

0 0
replied on April 19, 2017

Yes; I missed to tell you. Add the line below right below your document.ready code so that the message starts hidden.

 

$('.error_comments').hide();

 

The whole code should look something like this, if you didn't have any other javascript yet.

 

$( document ).ready(function() {
  $('.error_comments').hide();



$(document).on('click', '.Reject, .Approve, .Submit', checkComments);

//Make comments required when rejecting
function checkComments(){
  
  if($('#comments').val() == '')
  {

    $('#comments').css('border-color', '#ba0000');
    $('.error_comments').show();
     return false;
  }
  
}

$(document).on('focus', '#comments', remove_checkComments);

// removing border style on comments box focus
function remove_checkComments(){
  
  $('#comments').removeAttr('style');
  $('.error_comments').hide();
  
}



});

 

3 0
replied on April 18, 2017 Show version history

There are many examples for this in the different posts. I took from one and kind of modified it for our needs. What I did was to color the border of the comments box in red if it was empty upon submit. I also added an HTML box from the "Fields" section of the Layout screen and gave it a class name of (error_comments). The end result was like this.

Hope you can modify it for your needs

  $(document).on('click', '.Reject, .Approve, .Submit', checkComments);
  
  //Make comments required when rejecting
  function checkComments(){
    
    if($('#comments').val() == '')
    {

      $('#comments').css('border-color', '#ba0000');
      $('.error_comments').show();
       return false;
    }
    
  }
  
  $(document).on('focus', '#comments', remove_checkComments);
  
  // removing border style on comments box focus
  function remove_checkComments(){
    
    $('#comments').removeAttr('style');
    $('.error_comments').hide();
    
  }

 

backForMod.png
backForMod.png (7.16 KB)
3 0
replied on April 18, 2017

Hi,

I want to make it required and wont allow further task approval if it is left blank.

 

0 0
replied on April 18, 2017 Show version history

You want to change the style of the border or make it required and won't allow approve task when it is empty?

0 0
replied on April 19, 2017

Hello Xiuhong,

We want to make it required and don't allow approve task when it is empty.

Regards,

-Guillaume

You are not allowed to follow up in this post.

Sign in to reply to this post.