Solved

Numeric Field Format

Posted on 2001-07-23
17
283 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 

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
 

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

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

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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