Solved

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

Posted on 2003-11-17
14
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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