Copy link to clipboard
Copied
Hello,
I have a field that is a number that results (when entered) 999-99-9999. This is field "1a". I'm trying to get this result to show up in another field "a14a7" without the "-" between the numbers so it all comes together as 999999999. This is the script i wrote, which is pulling the number entered but my result still has the hyphens. Can anyone help me with this?
if(this.getField("1a").value)
{event.value=this.getField("1a").valueAsString}
else
{event.value=this.getField("").valueAsString}
Try this
if(this.getField("1a").value)
event.value=this.getField("1a").valueAsString.replace(/\-/g,"");
else
event.value=this.getField("").valueAsString;
Delete the script in "a14a7".
Only the validation script in "1a" is needed. This validation script moves the data in "1a" into "a14a7".
Copy link to clipboard
Copied
Try this
if(this.getField("1a").value)
event.value=this.getField("1a").valueAsString.replace(/\-/g,"");
else
event.value=this.getField("").valueAsString;
Copy link to clipboard
Copied
PERFECT!!! Thank you!
Copy link to clipboard
Copied
If you have a lot of calculations, then form performance could be improved by using a Validation script for this action instead of a Calculation script. Calculation scripts are run every time any field on the for is changed, whereas the Validation is only run when the specific field is changed. This solution works because field "a14a7" only get it's value from a single field. So that value can be pushed directly from the source field.
To do this, delete the calculation on field "a14a7", and then add this script to the Custom Validation script on "1a";
if(event.value)
this.getField("a14a7").value = event.value.toString().replace(/\-/g,"");
else
this.getField("a14a7").value = "";
Copy link to clipboard
Copied
Yes, i am having an issue. The result is pulling where i want it go. I even put in the validation script you suggested. The is, if i delete the number that was typed in "1a" it is not clearing in the other field.
Copy link to clipboard
Copied
try using just this code in the validation script for 1a, and make sure the name of the destination field ("a14a7") is correct, and that the original calculation script is deleted:
this.getField("a14a7").value = event.value.toString().replace(/\-/g,"");
Copy link to clipboard
Copied
Still not working. When enter the number in the field the first time, it seems to be working. When i delete it the number just stays. Here is the script i put in "a14a7":
if(this.getField("1a").value)
event.value=this.getField("1a").valueAsString.replace(/\-/g,"");
else
event.value=this.getField("").valueAsString;
and here is validation i put in:
this.getField("a14a7").value = event.value.toString().replace(/\-/g,"");
Copy link to clipboard
Copied
Delete the script in "a14a7".
Only the validation script in "1a" is needed. This validation script moves the data in "1a" into "a14a7".
Copy link to clipboard
Copied
Wow, that was very confusing and cool once i got my mind around it!!!
I think i'm getting this now. If, i didn't want to get rid of the hypens how would i change the script and the validation? So mirrorr with the script and validation what is in "1a"?
Copy link to clipboard
Copied
argh. When i deleted the number that was in 1a it did not clear out of a14a7
Copy link to clipboard
Copied
ok. it is in fact working! ty;