Form validation to display a button if form is valid

Hi Guys,

I have a submit button on a screen which needs to be displayed only when my form is valid.

All validations are done using a single isValid condition.

I am having trouble to trigger this validation which will in return display the submit button.

My concern is when should I trigger the validation as the user can fill the form in any order he/she wants.

Will I need to change my approach to validate the form if I want to implement this trigger?


Thanks in advance.

Ishan Wasnik

Hi,

I would suggest using the Validate button as default and if the form is valid then show Submit button.


Thanks

Hi Ishan,


The out of the box way this works, is that 

1) user fills in the form in whatever sequence he/she wants

2) user indicates he/she is ready with filling in by choosing a save button

3) save button 

  • triggers the built-in validations
  • in the logic there can be custom validations
  • in the logic, further processing is halted when one of the validations fail

4) on the screen, the problems are communicated to the user with red borders and messages

5) user can adjust and when ready, do save again


So let's turn this question around, what is the user experience you are trying to implement ? It sounds like you want to give some sort of early warnings to the user as soon as they fill in a wrong value, and don't want to wait until they choose the save button ?  Is that it ?  

I think you should be real carefull with this

  • don't give them feedback on inputs they haven't gotten to yet, that's annoying
  • for the most part, you can only do simple validations that don't involve more than one input
  • you won't be able to make use of built-in validations for this


As for the where, it will probably require you to have a blur event on all inputs, or something like that.  You could maybe have one single Action, tied to blur events of all inputs, keep a local copy of your entity with the previous value, and in this action see what value has changed and execute the validations for that input.

At the end of this Action, you'll also have to have logic to determine the IsValid boolean.  And just tie the availability of the submit button to that boolean.

Dorine

Hi Ishan,

You can use mandatory property for form fields to make sure he enters the values correctly. If not, when user submits the form without entering the values, client script validation will not even submit the form. There are lot of forge components like RestrictChars which can help you to achieve this functionality.

The other option when you cannot use mandatory property is to use server side validation but in this case use has to submit the form.

Another option I could think of is to use onChange property and add your own validation logic for each form field.

Hope this helps

Thanks

Ravi


Thanks for the reply Jitendra.

This approach was discussed and was not approved.

Another approach was to set onDisplay for button as form.valid and trigger ajax refresh for the button on each and every input widget. The form is quite big in terms of mandatory fields and ajax usage will be increased due to it.

Is there any approach which does not concern additional buttons or over usage of ajax refresh?

Ishan Wasnik wrote:

Thanks for the reply Jitendra.

This approach was discussed and was not approved.

Another approach was to set onDisplay for button as form.valid and trigger ajax refresh for the button on each and every input widget. The form is quite big in terms of mandatory fields and ajax usage will be increased due to it.

Is there any approach which does not concern additional buttons or over usage of ajax refresh?


Thanks for your clarification.


See we need some trigger to validate the full form

1. No need to add a new button

2. use the dynamic label for the button, default value = 'Validate'

3. check if the label has the value 'validate' then just do validation and once validate change the button label value to 'Submit' and when we click again call logic accordingly.


May be helpful.


Thanks!

What Dorine said ;)