Copy link to clipboard
Copied
We just converted to a digital version of our sales sheets for my company via PDF. I have each field vaildate with the "event.value = event.value.toString().toUpperCase() ;" script, which would be fine except the sales people are using Chromebooks where that function doesn't work, or really any JS. Basically they fill out the forms, save to a cloud, where we in the office can open them on our PCs.
The sales people we have are notorius for using lower-case for everything, proper names, etc. So our solution was to just have all caps on the forms. Problem is that Chromebooks do not have a caps lock, so we had to program the PDFs to do it. Unfortuately, as I mentioned, the books do not work with the validate function.
When we open them on our PCs with the lowercase fields, the fields will validate and the script will work to make the fields uppercase again, but ONLY if we modify the field. If we don't make changes, even tabbing across, nothing will validate and change.
Is there a simple way to make each field automatically change to uppercase when the documents are opened on our PCs if they were entered in as lowercase with the Chromebooks?
I was thinking a document-level script but I am not too sure how to go about it.
tl;dr
Need a script to automatically make certain field's values uppercase when opening the PDF.
Thank you! I hope what I am asking makes sense. I am new to JS with PDFs.
Yes, a document level script will work:
for(var i=0; i<this.numFields; i++)
{
var fieldName=this.getNthFieldName(i);
var oFld=this.getField(fieldName);
if(oFld.type=="text")
{oFld.value=oFld.value.toString().toUpperCase() ;}
}
You should include it because if any of the fields is not a string, the script will stop there, and it won't work on fields after that field (for example if the field is a number).
Copy link to clipboard
Copied
Yes, a document level script will work:
for(var i=0; i<this.numFields; i++)
{
var fieldName=this.getNthFieldName(i);
var oFld=this.getField(fieldName);
if(oFld.type=="text")
{oFld.value=oFld.value.toString().toUpperCase() ;}
}
Copy link to clipboard
Copied
Add: toString()
Copy link to clipboard
Copied
You can add that but it doesn't matter. Letter/number combos will be interpreted by the JavaScript engine as a string. Numbers might not, but there's nothing to convert to upper case, in that case.
Copy link to clipboard
Copied
I actually thought about adding that while I was putting the script in. The original worked, so I left it alone. Not too many uppercase numbers. 😄
Copy link to clipboard
Copied
@Nesa Nurani is a very knowlegable expert who has taught with a lot with her answers on this forum. She probably has a reason to include it that I hadn't thought of.
Copy link to clipboard
Copied
You should include it because if any of the fields is not a string, the script will stop there, and it won't work on fields after that field (for example if the field is a number).
Copy link to clipboard
Copied
Thanks @Nesa Nurani . Great knowledge as usual. I tested and it threw an error when it hit a number and stopped the script. Script corrected in my answer.
Copy link to clipboard
Copied
That did it. Thank you! I was going to ask about doing the same with title case, but since that seems to be a point of contention in the forums, I figured I would keep it simple. 😉