Hi,
Is it possible to set the Comments box in Laserfiche Forms as a compulsory field as shown below?
Please advise.
Hi,
Is it possible to set the Comments box in Laserfiche Forms as a compulsory field as shown below?
Please advise.
Thanks a lot, Raul. Indeed, it works perfectly.
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
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(); } });
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(); }
Hi,
I want to make it required and wont allow further task approval if it is left blank.
You want to change the style of the border or make it required and won't allow approve task when it is empty?