Jump to content

Limit characters in UniDBmemo


mierlp

Recommended Posts

Hi,

 

I have a UniDBMemo on a form where the user may enter max 80 characters,

I use the code below to display the amount of remaining characters with the

UniDBMemoChange event.

TextLen := 100-Length(StringReplace(StringReplace(UniDBMemo_Motivation.Text, 
 #10, '', [rfReplaceAll]), #13, '', [rfReplaceAll]));   
UniLabel_Count.Text:=intToStr(Textlen);

But how to prevent the user entering more than 80 characters ?

 

Regards Peter

 

Link to comment
Share on other sites

Hi mierlp.

Try this:

Add the code in UniDBMemo1.ClientEvents.ExtEvents

function OnChange (sender, newValue, oldValue)
{
   if (sender.getValue().length > 80)
   {
     sender.setValue(sender.getValue().slice(0, 80));
   }
}

This is one of the solutions

Sincerely.

  • Upvote 2
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...