Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Having issue with making a script I had written works okay


Level 4

Dear All,

I am working on a form, that requires the Signature fields to be "readOnly", unless the two fields fields before it are completed. If the fields are not completed it should show a message, but if these fields are completed no message should show.

I wrote the following script and put on the on enter event of the Signature field, but it does not work well.

var v;

if(form1.Page1.Reviewerssignat.rawValue ==null){


  v=xfa.host.messageBox("Please Complete Supervisor  and Senior Supervisor fields");


else if(form1.Page1.Reviewerssignat.rawValue !=null){  




Please can someone out there tell me why it is not working.



1 Reply


Level 7

I don't see anything syntactically wrong with this. The problem appears to be that you're checking the field you are entering. Essentially, you're script is saying, "If this field I just entered is empty, then I want to make it read only."

If you're not absolutely set on the idea of making the field read only, you could instead set focus to one of the fields that needs to be filled.

Try this for the enter event of your field that you want to protect when the other two aren't filled.

if (TextField2.isNull) {

  xfa.host.messageBox("You missed a spot");


} else if (TextField3.isNull) {

  xfa.host.messageBox("You missed a spot");



(Of course, change the names of TextField2 and 3 to match what your field names, and change the message to be more meaningful. ) Now, this doesn't make that field readOnly, but you can't do anything with it unless those fields are filled. If you only need one or the other to be filled, you could change the logic slightly by adding an if statement that surrounds this to check that they are both empty before proceeding.