This code will do it:
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null) f.readonly = true;
}
Another option is to use a digital siganture field and sign the document before sending it. The validity of the signature guarantees that the file hasn't been tempered with.