2 Submit buttons in a form,

  • 3 January 2019
  • 4 replies
  • 46 views

Badge +6

Hi all,

I have 3 buttons in a form, one save button and other 2 are save and submit buttons. save will be saving the data to list without any validations.

i am facing issue while submitting the data. My scenarios are as explained below.

1. When they click on submitggg button only ggg Text filed filed should be mandatory.

2. When they click on submitnnn button only nnn Text filed filed should be mandatory.

So i have written 2 rules validating both.

For submitggg button--  isNullOrEmpty(Ggg)

For submitnnn button --  isNullOrEmpty(nnn)

But now whichever the submit button i click both the validations are triggering. How to avoid this situation?

221839_pastedImage_1.png

Regards,

Hema


4 replies

Userlevel 4
Badge +12

Hi!

Submit will always cause all validation rules to validate. If you have scenarios like this you will have to create more complex vaidation rules or use java script to determine which button was clicked and run a custom validation method.

One solution without javascript could be to have a control that determines the scenario and just have one save and submit button. The control coult be a check box or a dropdown for excample.

Let's say it's a checkbox with the name "isNNN" then the validation could be like

and(isnnn, isNullOrEmpty(nnn)) or and(not(isnnn), isNullOrEmpty(nnn))

If it's a dropdown with the name scenario it could look like

and(contains(scenario, "nnn"), isNullOrEmpty(nnn))

Does this make sense? Would it be helpful for you?

Best regards

Enrico

Badge +6

Thank you for the suggestion. i will go with the Javascript since i have more than 1 submit button in my form.

Userlevel 6
Badge +12

Hema manjunath‌ - 

What about hiding the buttons until the control is Not(isNullOrEmpty())

This way they cannot Save and Submit until one of them is filled in. The only issue that this would cause is what happens if they enter data into both controls?

Perhaps once they add something to one control it shows the Save&Submit button as well as hides the other control?

Hope this helps!

Userlevel 7
Badge +17

This is what i've done in this situation. I disabled the button (instead of hide) when the condition was not met. So disable the submitggg button when ggg is null or empty. Then have no validation rules.

Reply