Solved

Numeric Field Format

Posted on 2001-07-23
17
284 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
[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
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
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!

 

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

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

734 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