Copy link to clipboard
Copied
Why this doesn't work?
var f = this.getField("Text2").value;
var reg = /\+?\d+/;
var str = f.match(reg);
event.value = str;
I tested it in that site w3.schools.com and there it works, but in pdf it doesn't work.
Use this code:
var f = this.getField("Text2").value;
var reg = /\d+/;
var str = f.match(reg);
if (str!=null) event.value = str[0];
else event.value = "";
Copy link to clipboard
Copied
You need to explain what you're trying to achieve...
Copy link to clipboard
Copied
I want to extract first number from "Text2".
Copy link to clipboard
Copied
Use this code:
var f = this.getField("Text2").value;
var reg = /\d+/;
var str = f.match(reg);
if (str!=null) event.value = str[0];
else event.value = "";
Copy link to clipboard
Copied
Thank you.