0

The objective of this problem is to pop a warning message if user hit submit button with no address and take no action, but the problem is submit button don't have click event.

I am checking a address field, if the address field has some value then it should proceed to submit the form, otherwise it should popup a message and don't take any action.

 Form.#pageSet[0].Page1.FOOTER_EN_FRAGMENT.FSSUBMIT_PC::mouseUp - (JavaScript, client)

    var addr1 = HEADER_EN_FRAGMENT.CUSTOMER_ML_ADDRESS_1.rawValue;
    var addr2 = HEADER_EN_FRAGMENT.CUSTOMER_ML_ADDRESS_2.rawValue;

        if(addr1  == null || addr1  == "" || addr2 == null || addr2  == "")
        {
          app.alert("Address field can't be blank!",3); 
          FSSUBMIT_PC.validate = "disable";//need help here
        }

Right now its just displaying the error message, but still submitting when button is click. I want it to take no action but I don't know how to do that in adobe livecycle designer.

Also please tell me if there is any other way to pop up error message other than app alert.

Thanks in advance!

Rishabh Agarwal
  • 2,374
  • 1
  • 21
  • 27

2 Answers2

1

I would do it like that I think:

var addr1 = HEADER_EN_FRAGMENT.CUSTOMER_ML_ADDRESS_1;
var addr2 = HEADER_EN_FRAGMENT.CUSTOMER_ML_ADDRESS_2;

if(addr1.isNull || addr2.isNull)
{
    app.alert("Address field can't be blank!",3); 
    xfa.event.cancelAction = 1; //This worked for me for cancelling the print process, maybe it will work for you too!
}

And I wonder why you did it in the mouseUp-event, and not in click.

App.alert ist usually the quickest way but if you want to try out different stuff I recommend reading about custom dialogs - e.g. here.
There's also an older xfa version: MessageBox Docu.

Cold_Class
  • 3,214
  • 4
  • 39
  • 82
0

So basically what I learned each button has 3 control type regular, execute and submit. In submit and execute button type we can have click event so what we need to do, add a second button with control type regular and place it over the first button with control type submit and in second button click even call first button,

 var addr1 = form1.Page1.HEADER.CUSTOMER_ML_ADDRESS_1.rawValue;
 var addr2 = form1.Page1.HEADER.CUSTOMER_ML_ADDRESS_2.rawValue;

 if(addr1 == null || addr1 == "" || addr2 == null || addr2 == "")
 {
    xfa.host.messageBox("Address field cannot be blank.");  
 }
 else
 {
      FSSUBMIT_PC.execEvent("click");
 }
Rishabh Agarwal
  • 2,374
  • 1
  • 21
  • 27