Solved

Limiting the Text field to certain number of characters in Notes Client Dynamically

Posted on 2003-11-17
14
344 Views
Last Modified: 2013-12-18
Hi Experts

Is there any possibility to limit the Text field to a number of characters in Notes Client ?

That is If I decide to have the maximum size of the Text field  to be 10 characters then the user should not be allowed to type 11 th character.

 I dont want to pop up any error but I just want to restrict him from typing further. I know an input validation can be done on the field.

But it can check only when the document is refreshed or saved. But what I want to do is limit the text field size.

Hope you people help me.

Thanks in Advance
Vinothini Kasiviswanathan
0
Comment
  • 6
  • 2
  • 2
  • +1
14 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 9769461
Try Input Translation
0
 
LVL 19

Accepted Solution

by:
madheeswar earned 50 total points
ID: 9769466
And here is the code where I found in notes.net

You can do it like this (place these subs on the Form).
I think this is quite self-explanatory. Change the const "fieldname" statement to the field name you want to control, and the "fieldmaxlen" to the max. length you want to allow to type in:

(Declarations):
Dim elapsedTimer As NotesTimer

Sub Postopen(Source As Notesuidocument)
Dim session As New NotesSession
Set elapsedTimer = session.CreateTimer()
elapsedTimer.Interval = 1
On Event Alarm From elapsedTimer Call elapsedTimerHandler
End Sub

Sub elapsedTimerHandler(Source As NotesTimer)
Const fieldname="subject"
Const fieldmaxlen=30
Dim workspace As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=workspace.currentdocument
s=uidoc.fieldgettext(fieldname)
uidoc.fieldsettext fieldname,Left(s,fieldmaxlen)
End Sub
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9769500
Translation:
@Left(fieldname;4)
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9769569
If you are telling that when the types 11th character, then notes should not accept it, then tis not possible. In Notes client we don't have the event.

We have events on web and we can use Java Script for this.

0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9769575
For Translation:
@If(@length(sendmails_k)>4;@Prompt([OK];"Ur Prompt";"Prompt msg")&@Return(@Left(sendmails_k;4));sendmails_k)
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9769588
Else use Script in Exiting event.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 50 total points
ID: 9771076
Notes doesn't support onChange or direct size limits, but you can use an external control, such as the ones that come with MS office, and script it in (moving teh value into a hidden field).
0
 

Expert Comment

by:David777
ID: 9776998
input translation seems not be able to change value realtime, it only proceed on save or refresh. But I remember in notes version 6, it supports onChange event in notes client. I check it....

yes, you can put lotus script/java script under onChange event in notes client as well as web
0
 

Expert Comment

by:David777
ID: 9777001
I don't remember notes support direct field size limits.
0
 
LVL 4

Assisted Solution

by:bhartung
bhartung earned 50 total points
ID: 9907511
You'll have to forgive my inability to recall specifics, but I remember back in Notes 4.5 (circa 1997) we were able to accomplish this if the field was defined in a layout region (layout section?  how the memory fades...)  If that was the case, it was possible to get the window handle for that control and use Win32 API calls to set the window properties (it was probably a SendMessage call) to cause the text control to behave as you wish, where the cursor simply stops dead at the nth character.  Darned if I can remember the specifics, but at least you can take away from this rambling the fact that under certain conditions it has been done in the past.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9909783
bhartung,
Cool tip.  Too bad the thread rotted.
0
 
LVL 4

Expert Comment

by:bhartung
ID: 9912903
The horse is dead, but let's beat it a little more...

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const EM_LIMITTEXT = &HC5

Given hwnd, the window handle for the control inside the layout region, the following example would set the upper bound on enterable/pastable text to 30:

SendMessage hwnd, EM_LIMITTEXT, 30&, 0

I recall that we ran this code any time the control got focus.

Hope this helps anyone poking through the archives at least...
-B
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now