Numeric Field Format

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.
PucktargetAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
HemanthaKumarConnect With a Mentor Commented:
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
 
HemanthaKumarCommented:
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
 
PucktargetAuthor Commented:
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
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.

 
PucktargetAuthor Commented:
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
 
HemanthaKumarCommented:
Substitute the fieldnames appropriately

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

There is absolutely no version problems !
0
 
GwrCommented:
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
 
PucktargetAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
PucktargetAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
PucktargetAuthor Commented:
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
 
HemanthaKumarCommented:
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
 
PucktargetAuthor Commented:
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
 
HemanthaKumarCommented:
Use this in Iput translation

temp := @Text(@TextToNumber(obligor));
@Repeat("0"; 10-@Length(temp)) + temp
0
 
pafrokCommented:
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
 
ZvonkoSystems architectCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.