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

Question

Question

Character limit on Multi-line field is not working

asked on July 19, 2017

Hi,

We are testing one of our solution and here is what happens. There is a multi-line field with character length set to 1000 where users tend to copy paste text from a Word doc or email at the time of submission. So there is a potential for carriage return and bullet points etc. to be copy-pasted.

I have always believed that the truncation takes place automatically at the set limit but somehow its failing and below is what happens.

The text below has 1000 characters and form doesn't display any error but the submission fails with the below error.

Does anyone know how to fix this issue?

ERROR WHEN THE FORM IS SUBMITTED:`

TEXT USED IN THE MULTI-LINE FIELD:

The Panasonic Lumix DC-GH5 is the fifth in the company's industry-changing video and stills 'hybrid' lineup. With its 20MP Four Thirds sensor and deep video-centric feature set, it looks likely to pick up where the GH4 left off as a favorite of indie filmmakers and photographers whose interests venture into the realm of motion picture work.
The GH5's feature set moves on suitably far from its predecessor that the company says the GH4 will remain in its lineup as a lower-cost option for users who don't need the additional capability that the GH5 brings.
For many users, the addition of in-body stabilization and 4K video without cropping might be enough to make the camera a worthwhile upgrade, but Panasonic has revised and improved almost every aspect of the camera's behavior and performance.
Key Features
• 20MP Four Thirds sensor (no OLPF)
• 5-axis in-body image stabilization system with 'Dual IS 2' support
• All 4K footage taken using full width of sensor (oversampled from 5.1K footage)

 

ERROR IN EVENT VIEWER:

Errors encountered during forms submission: <br>Field Name: Notes, Position: 12, Error: This value exceeds the given character limit. [LFF9303-ValueExceedsCharacterLimit] [LFF9312-ErrorOccuredDuringFormsValidation]<br> You can click the back button on the browser to correct and resubmit the form. [LFF9320-FormsValidationAggregateException]

Details:
URL: /Forms/Form/Submit
Error: FormsValidationAggregateException
Date: 20/07/2017 14:01:04 (AUS Eastern Standard Time)
HTTP Status Code: 400
Business Process ID: 25
User: DOMAIN\USER.NAME
IP: 192.168.64.108
Browser: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
Business Process Name: Procurement 01 - Advise Approvals Outcome

Stack Trace:
Caught exception: Laserfiche.Forms.CommonUtils.Exceptions.LFFormsException
Message: Errors encountered during forms submission: <br>Field Name: Notes, Position: 12, Error: This value exceeds the given character limit. [LFF9303-ValueExceedsCharacterLimit] [LFF9312-ErrorOccuredDuringFormsValidation]<br> You can click the back button on the browser to correct and resubmit the form. [LFF9320-FormsValidationAggregateException]
   at E_Forms.Models.ViewModels.Form.Submit.GetErrorMsgFromAllErrors(BlockingCollection`1 exceptions)
   at E_Forms.Controllers.FormController.Submit(FormCollection collection)
   at lambda_method(Closure , ControllerBase , Object[] )
   at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

0 0

Answer

SELECTED ANSWER
replied on July 20, 2017

Hi Adarsh,

Are you using Forms 10.2.0? There is a known issue that new line was considered as two characters in backend validation of Forms 10.2.0, so the counting was not correct.

The issue has been fixed in 10.2.1. Sorry for the inconvenience.

0 0
replied on July 26, 2017

Yes, we are using 10.2.0.

0 0

Replies

replied on July 25, 2017 Show version history

Hi Rui,

 

Thanks for answering. Upgrading to 10.2.1 is not an option for us now. Please can you provide a simple patch to fix this? Also temporarily, please can you give us a CSS workaround to alert the user before the submission?

Thanks,

Adarsh

0 0
replied on July 25, 2017

For providing individual patch, can you please open a support case for it? We can't give you patch directly without a support case.

For temporary fix, you can add the following custom JavaScript (*not CSS) and add CSS class custom-limit to the multi-line field:

$(document).ready(function(){
  window.Parsley.addValidator('climit', {
    validateString: function (value, maxlength) {
      var element = arguments[2].$element;
      var realValue = $(element).val();
      var newLines = realValue.match(/(\r\n|\n|\r)/g);
      var addition = 0;
      if (newLines != null) {
        addition = newLines.length;
      }
      if (realValue.length + addition > maxlength) {
        return false;
      }
      return true;
    },
    messages: {
      en: 'Text length should not exceed %s.',
    }
  });
  $('.custom-limit textarea').attr('data-parsley-climit', $('.custom-limit textarea').attr('maxlength'));
  $('.custom-limit textarea').removeAttr('maxlength');
})

 

1 0
replied on July 26, 2017

Thank you for the JavaScript, it works as you'd expect. I have raised a support ticket for the patch.

 

Thanks,

Adarsh

0 0
replied on July 20, 2023

This helped me in 2023.

Thanks,

Christine

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

Sign in to reply to this post.