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

0 (Zero) values are not accepted for required fields?

nepomucenobr
Registered: Jul 27 2010
Posts: 10
Answered

Hi everyone,
 
I have this textfield with "required" property set to true. The thing is if I type 0 (zero), Acrobat is giving a message saying that the highlighted fields are mandatory. For this case, 0 IS a valid value. What should I do?

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
It is often best to create your own routine to check for correctly completed fields. It is a much more flexible approach.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
By the way, which version of Acrobat are you using?
nepomucenobr
Registered: Jul 27 2010
Posts: 10
Tks George! In fact, I am using my own routine but (formField.value == '') was returning true for a field that the user typed 0 there.

Then, I tried formField.value.toString() == '' and it solved the problem.

Btw, I am using Acrobat Standard 9.0.0.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
If you want to compare zero and a null character string, you should use the field's 'valueAsString' property for all the text type fields being tested and then you could just check all text fields or even non-button fields with the same field property.

George Kaiser

nepomucenobr
Registered: Jul 27 2010
Posts: 10
I see but is there any difference between valueAsString and value.toString()?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
The valueAsString property will pickup the value as entered and not formatted. This becomes helpful when one wants to retain leading zeros for values being used in other calculations.

George Kaiser

nepomucenobr
Registered: Jul 27 2010
Posts: 10
You're right, thank you. But in this particular case as I am testing empty string, won't make any difference, right!? :)
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
It will not make a difference. I wrote a generalized function to check for the 'required' property and used the the 'valueAsString' for all the text fields, it just made the function simpler and I did not need to know anything else about the field except that it was a text field.

George Kaiser