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
Solved

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

Posted on 2003-11-17
14
352 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

  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.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

792 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