These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Strange Validation behavious

Mark Thorne
Registered: Feb 19 2011
Posts: 2
Answered

Hello, I'm not new to Javascript, but I am new to Acrobat, and I'm having a strange problem that I can't seem to figure out regarding form validation. My understanding is that the validation event is triggered on an onBlur event of the field, which is all good, but the weird part is that it seems to be validating the value that was held in the field before editing, not the new value. For example, if there's a 4 in the field and I change it to 5, then click outside the field to trigger the onBlur, it will run validation against the 4 and not the 5. Here's the code I'm using to test this, in case anyone is wondering.
 
fValue = getField("field10").value;
var sayMe = "Value is: "+fValue;
app.alert(sayMe);
 
So if I have a 4 in the field, then enter 5 and click a different field, it will return "Value is: 4" then if I change the now entered 5 to a 3, it'll return "Value is: 5" and so on.

My Product Information:
Acrobat Pro 10.0.1, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Accepted Answer
No, the Validate event is triggered when the field value changes. The new value of the field is given by the value property of the event object, so the code should be:

fValue = event.value;
var sayMe = "Value is: "+fValue;
app.alert(sayMe);


Note that the type of event.value is always a string, which is not the case with the value property of a field.



Mark Thorne
Registered: Feb 19 2011
Posts: 2
Thanks George, that set me on the right path.