Skip to main content
Participating Frequently
August 27, 2021
Question

How do i auto populate a text field from other text field

  • August 27, 2021
  • 2 replies
  • 1051 views

Hallo everyone, 

 

i need your helh about generating auto text field. If i have two text fields a and b. Once i enter any number in a, it generate my signature in b (i have already did this part). thanks in advance 

 

This topic has been closed for replies.

2 replies

Participating Frequently
August 27, 2021

@ls_rbls  thanks for your quick response. 

 the signature is in a Text box (this.getField("Textfeld13").value = gUserName; ), in my case i need to insert material number in text box (a), then the username will be generated in (b)

ls_rbls
Community Expert
Community Expert
August 27, 2021

Will all of these material numbers consist of 7 digits with this format: "1.2345.67" ?

Participating Frequently
August 27, 2021

the size of the material number differs from one part to other, but it would be like (81645420651)

ls_rbls
Community Expert
Community Expert
August 27, 2021

How are you fetching your signature? Is it a digital signature field? a custom stamp?

 

Where is this signature located?

 

In any case, I would test if the event value of the target field "a" is not a number (NaN) using a custom validation script  like:

 

 

event.rc = false;

var mySignature = "Me, my self and I"
var f = event.value/event.value;

if (f !== 1) { 

  this.resetForm(["b"]);
 
  event.rc = true;


} else {

  if (f !== NaN) { 

  event.rc =

  // insert your script here 
  
  this.getField("b").value = mySignature;

 }
}

 

 

If the event value is indeed a number, and it is divisible by itself, it will equal 1. So if it is a number, your script will execute and populate field "b" with whatever script you have that generates your signature.

 

In my example above, I've declared a variable with "Me, my self and I" as an example for any given name to poplate field "b" if the event value is a number divisible by itself to equal 1.

 

Any other event value that is not a number will produce "NaN" as a result and field "b" will reset and clear.

try67
Community Expert
Community Expert
September 3, 2021

This is not going to work.

For starters, this is a very odd way of checking a field's value, by dividing it by itself and checking if the result is either 1 or NaN. There are much better and more predictable ways for that.

Also, that's not how you check if a value is NaN. You need to use the isNaN method for that.

Try this code and see that it returns false:

(0/0)==NaN

This returns true:

isNaN(0/0)

ls_rbls
Community Expert
Community Expert
September 3, 2021

Thank you Try67.

 

I wasn't checking for NaN. And I  wasn't checking for an undefined value like  zero divided by zero.

 

Neither was I  looking into a whole number divided by another whole number that is greater than the first one, by which the quotient is not equal to zero.

 

Since the OP was etremeley vague in providing answers to how the material numbers format would look like, What I was looking into Is a simple mathematical rule and it is also one of the properties of Division: "Division by itself Property".

 

So I was observing the results that the debugging console was throwing back when a value entered in the field had special characters.

 

I  noticed that everytime I entered N799-5, for example, and divided it by itself , it will log NaN.

 

On the other hand, If the value entered in the field was typed in 7995 (with no special characters), the console will throw back a vlaue of 1 due to the division property applied through the custom validation script.