Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to disable submit more than once?

Avatar

Level 2

Hi,

I have a form with a huge number of fields and validations on their validate event.

The form has a submit button with the following routine:

myDoc.submitForm(

{

     cURL: URL,

     cSubmitAs: "PDF"

}

);

My goal is that the user will be able to submit the form only once.

If I hide the submit button after this script there is a chance that one of the fields not pass the validation, the button disappear and user is not able to submit any more.

Otherwise nothing avoid from the user to submit the form multiple times.

Anyone has an idea?

2 Replies

Avatar

Level 9

Hi,

In the click event of the submit button you can write some scripts to prevent the user from submitting unless the field passes the validation test.

if (form1.Page1.execValidate())

     {

myDoc.submitForm(

{

     cURL: URL,

     cSubmitAs: "PDF"

}

);

}

else

     {

          app.alert("Please fill the fields first");

     }

Or you can create a hidden submit button. In the click event of this button write the script for the submission. Then inside the if statement call the click event of this hidden submit button. like : Hidden_submit_button.execEvent("click");

Thanks,

Bibhu.

Avatar

Level 3
Level 3

here you can use

if()

{

}

else if()

{

}

else if()

{

}

else

{

  write code that you want to execute in last.

}

Untill top conditions are not satisfied, code below that condition will not be executed. So no need to disable submit button because when user will click on submit button it will check all the condition from top.

Thanks