Skip to main content
Participant
December 20, 2018
Answered

Calculate Text- and Datefields

  • December 20, 2018
  • 1 reply
  • 612 views

Hello,

I want to create a Form with several fields.

Two of these fields include the first- and the lastname of the person, written in a field with 30 letterboxes each.

1. How can I use this data in another field with different formation (no letterbox)?

2. And how can I calculate the full-name ( <lastname> & ", " & <firstname>) in another field in this form?

The same problem I have with the birthdate. The first field is again a letterbox with 6 digits: ddmmyy.

In another field the date should be written again, in a no-letterbox, with the format: dd.mm.yyyy

It's a long form, so it would be nice if I have to fill each information just once.

This topic has been closed for replies.
Correct answer try67

Not sure what you mean by "no letterbox", exactly... If you mean the user can't edit it then you just need to set the field as read-only, under its Properties, General tab.

For the full name field use this code as the custom calculation script of that field:

var firstName = this.getField("firstname").valueAsString;

var lastName = this.getField("lastname").valueAsString;

if (firstName && lastName) event.value = lastName + ", " + firstName;

else event.value = "";

For the DOB field:

var dob = this.getField("dateofbirth").valueAsString;

if (dob) event.value = dob.substring(0,2)+"."+dob.substring(2,4)+"."+dob.substring(4);

else event.value = "";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 20, 2018

Not sure what you mean by "no letterbox", exactly... If you mean the user can't edit it then you just need to set the field as read-only, under its Properties, General tab.

For the full name field use this code as the custom calculation script of that field:

var firstName = this.getField("firstname").valueAsString;

var lastName = this.getField("lastname").valueAsString;

if (firstName && lastName) event.value = lastName + ", " + firstName;

else event.value = "";

For the DOB field:

var dob = this.getField("dateofbirth").valueAsString;

if (dob) event.value = dob.substring(0,2)+"."+dob.substring(2,4)+"."+dob.substring(4);

else event.value = "";

JStielerAuthor
Participant
December 20, 2018

That solved all my problems. thx!