Skip to main content
Participant
August 22, 2018
Answered

get Alert when max characters reached

  • August 22, 2018
  • 3 replies
  • 832 views

I have set a character limit for a Textfield.

i try to show the remaining characters without success.

alternatively i try to show an error message when the limit is reached

var laenge = this.getField("Overline").value;

event.rc = true;

if (laenge > 10)

  {

     app.alert("Max. 40 characters incl. spaces");

     event.rc = false;

  }

else

{

    event.target.textColor = color.black;

}

Is there a way to display the remaining characters?

if not, what am I doing wrong with the code here?

This topic has been closed for replies.
Correct answer gkaiseril

A more complex way of performing this task:

Countdown Maximum Length Input

The approach used by D.P. Story is to use the "AFMergeChange()" function to obtain the length of the form field being filled in dynamically.

3 replies

gkaiserilCorrect answer
Inspiring
August 22, 2018

A more complex way of performing this task:

Countdown Maximum Length Input

The approach used by D.P. Story is to use the "AFMergeChange()" function to obtain the length of the form field being filled in dynamically.

try67
Community Expert
Community Expert
August 22, 2018

Where did you place this code? Under what event?

Bernd Alheit
Community Expert
Community Expert
August 22, 2018

Try this:

var laenge = this.getField("Overline").value.length;

ayr4nAuthor
Participant
August 22, 2018

unfortunately did not work.

i also try var laenge = this.getField("Overline").value.toString().length; without success.

Bernd Alheit
Community Expert
Community Expert
August 22, 2018

Use following lines:

console.show();

var laenge = event.value.length;

console.println("laenge: " + laenge);