Solved

Numeric Field Format

Posted on 2001-07-23
17
279 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Substitute the fieldnames appropriately

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

There is absolutely no version problems !
0
 

Expert Comment

by:Gwr
Comment Utility
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
Comment Utility
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
Comment Utility
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
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!

 

Author Comment

by:Pucktarget
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Use this in Iput translation

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

Expert Comment

by:pafrok
Comment Utility
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
Comment Utility
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

Highfive Gives IT Their Time Back

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

771 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

12 Experts available now in Live!

Get 1:1 Help Now