AnsweredAssumed Answered

Issue with validation of number fields with currency and thousand separator in AlfrescoShare

Question asked by ispasojevic on Oct 4, 2017

Hello everyone,

 

I'm trying to add currency and/or thousand separator to number fields in AlfrescoShare($ 123.456,78 or 123.456,78 format). I've already created new form control that displays value in currency format, but I have problem with number validation. I tried to add custom form validation that converts currency number format to number that is recognized by Alfresco Share  but without success. 

I have also customized  Alfresco.forms.validation.number method for validation of number fields to include currency format, but on submit I'm getting Number format exception ("for input string", and "too many points" if I have more than one thousand separator) without any exception trace in log files. 

I tried also with Form Filter, but filter is on the repo side, and this is obviously Alfresco Share validation.

   Is there any way to display number fields in currency format (or format with thousand separator) and validate it on Alfresco Share as number?

 

My custom form control:

<#setting number_format="currency">

   <#if form.mode == "view">

      <div class="viewmode-field">

         <#if field.mandatory && !(field.value?is_number) && field.value == "">

            <span class="incomplete-warning"><img src="${url.context}/res/components/form/images/warning-16.png" title="${msg("form.field.incomplete")}" /><span>

         </#if>

         <span class="viewmode-label">${field.label?html}:</span>

         <span class="viewmode-value"><#if field.value?is_number>${field.value}<#elseif field.value == "">${msg("form.control.novalue")}<#else>${field.value?html}</#if></span>

      </div>

   <#else>

      <label for="${fieldHtmlId}">${field.label?html}:<#if field.mandatory><span class="mandatory-indicator">${msg("form.required.fields.marker")}</span></#if></label>

      <input id="${fieldHtmlId}" type="text" name="${field.name}" tabindex="0"

             class="number<#if field.control.params.styleClass??> ${field.control.params.styleClass}</#if>"

             <#if field.control.params.style??>style="${field.control.params.style}"</#if>

             <#if field.value?is_number>value="${field.value?string.number}"<#else>value="${field.value?html}"</#if>

             <#if field.description??>title="${field.description}"</#if>

             <#if field.control.params.maxLength??>maxlength="${field.control.params.maxLength}"</#if>

             <#if field.control.params.size??>size="${field.control.params.size}"</#if>

             <#if field.disabled && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if> />

   </#if>

Outcomes