Solved

Numeric Field Format

Posted on 2001-07-23
17
281 Views
Last Modified: 2013-12-18
Hello all.  I have a form in a shared database that I have a question on formatting.  

First of all, is there any way to get a message box or some type of warning to appear after tabbing off the field if text has been placed in the field.  Currently the warning only pops up upon clicking the send button.

Also, can you set the length of the field to a certain amount (ie: 10 characters), and can you have the field insert zeros in front of what the user inputs to the field lenth.  Example: If user inputs 12345, the field automatically fills in five zeros in front to make the number 0000012345.  

Eventually we would like to do some sort of "scrape" from one of our systems that has numbers in this format so this would help a lot.
0
Comment
Question by:Pucktarget
17 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6309718
Use this function to determine if it is a number or text, @IsNumber( value ) in Input validation event of the field

the second question is doable only when the field is of type text. As padding of zeros for numeric will strip out that and gives you whole int.

~Hemanth

0
 

Author Comment

by:Pucktarget
ID: 6309768
Ok.  If I can't set the length in a numeric field, can I set it in a text field and have it prefill the leading zeros?

Thanks
0
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 200 total points
ID: 6309834
yes

use this function in the input translation
@Repeat("0"; 10-@Length(FieldName)) + FieldName


and this in Input validation

@if( @length(FieldName) > 10; @Failure("Field 'field name ref' cannot accomodate more than 10 digits"); @Success)


Remember to check the Automatically refresh fields prop of the form, this will fire the above said events

~Hemanth
0
 

Author Comment

by:Pucktarget
ID: 6309974
I tried your code and it did not work.

Is this code written for any particular version, or will it work in any version.

We are running 4.6.2 at the moment.

Pucktarget
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6310029
Substitute the fieldnames appropriately

I used "FieldName" , which is the field in context .

There is absolutely no version problems !
0
 

Expert Comment

by:Gwr
ID: 6311249
Hi
you can also use the "Exiting" Event (Lotus Script)of the field and do whatever you want there, But I agree with Hemantha, Input validation is the best place to do it.
Gwr
0
 

Author Comment

by:Pucktarget
ID: 6312387
Thanks Hemantha!!  I got it working this morning.  Quick question.  It is set as a text field and it works fine.  Is there any way to have the field validate the field to make sure all characters in it are numeric.

I put this script into the Exiting event:

Sub Exiting(Source As Field)
     Dim obligor As Integer
     If Isnumeric(0) Then Msgbox "Please make sure that Obligor is numeric only."
End Sub

The message box works fine but comes up no matter what type of character is input into the field.

Thanks!!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6312538
In Input validation event of the field "FieldName" , @IsNumber( FieldName ) will do the trick

eg:

@If( @isNumber(FieldName); @Success; @Failure("FieldName can contain only numeric values"))

Disadvantage of exiting it it will fire the msgbox and will go on, but validation will fire until the value is correct.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Pucktarget
ID: 6312721
Thanks for the help.  Still can't get it to validate if all characters are numeric.  This is what I have in the input validation field.  Sorry for the confusion, I am new to the Notes environment.


@If( @IsNumber(obligor); @Success; @Failure("Obligor can contain only numeric values"));
@If( @Length(obligor) > 10; @Failure("Obligor cannot accomodate more than 10 digits");
@Success)
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6312862
Hey everyone start a fresh with notes environment and there is nothing to be sorry for !

Try this

@If( !@IsNumber(obligor); @Failure("Obligor can contain only numeric values"); @Length(obligor) > 10; @Failure("Obligor cannot accomodate more than 10 digits"); @Success)
0
 

Author Comment

by:Pucktarget
ID: 6313101
Getting closer.  Error message hits if a text character is in the field, but it also hits if field contains all numbers as well.

Thanks again.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6313854
I think it is testing the data type of the field, try this this works

@If( @IsError(@TextToNumber(obligor)); @Failure("Obligor can contain only numeric values"); @Length(obligor) > 10;
                     @Failure("Obligor cannot accomodate more than 10 digits"); @Success)

Sorry for the hassle

~Hemanth
0
 

Author Comment

by:Pucktarget
ID: 6313962
No hassle.  Believe me I appreciate your help.  I am going to bump this up to 200 for you when I get this solved.  I have been building forms for a year but I am only now beginning to realize all the potential that is in them.  So I am revisiting some of my forms to improve them.

Ok...if the field is all numeric it is fine, the zeros are prefilled nicely upon document being sent.  The greater than 10 characters function is also working.  But it still will not kick an error for text in the field.  Is this because of the leading zeros function (or can this do both) and that the properties of the field is text.

Thanks again!!
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 6314713
Use this in Iput translation

temp := @Text(@TextToNumber(obligor));
@Repeat("0"; 10-@Length(temp)) + temp
0
 

Expert Comment

by:pafrok
ID: 6326407
you could try using javascript in the onBlur event:

function checkNumeric(teststr)
{
var foundstr = '';
valid = new Array('1','2','3','4','5','6','7','8','9','0','-');
for (var i=0; i < teststr.length; i++)
     {
     foudstr = 'No';
     for (var j=0; j < 11; j++)
          {
          if(teststr.charAt(i)==geldig[j])
               {foundstr = 'Yes'};
          }
     if (foundstr == 'No')
          {return '1'}; };
return '0';
};
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 10476298
Pucktarget,
No comment has been added lately (946 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to HemanthaKumar http:#6309834
Please leave any comments here within 4 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

Zvonko
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

27 Experts available now in Live!

Get 1:1 Help Now