ngFormBuilder icon indicating copy to clipboard operation
ngFormBuilder copied to clipboard

field validation on click of the disabled submit button

Open StefanHoutzager opened this issue 9 years ago • 8 comments

I see that validations on fields are executed when you leave them. Is it possible to validate all fields when clicking on the disabled submit button? Maybe it would be good to have this as default behaviour.

StefanHoutzager avatar Jan 04 '17 15:01 StefanHoutzager

@StefanHoutzager whats your use case for this functionality? Validations happen on the blur event, as you correctly mentioned, but I don't feel good about giving a disabled button any functionality.

zackurben avatar Mar 29 '17 22:03 zackurben

I've seen the fuctionality at least in https://github.com/1000hz/bootstrap-validator (lots of stars). Some discussion wherein the functinality is named: https://github.com/1000hz/bootstrap-validator/issues/443. Usecase is that a user, which maybe did not touch every input with a validation, should be able to see what's wrong. That the submit button is disabled indicates the input is not ok, but not what is not ok.

StefanHoutzager avatar Mar 30 '17 12:03 StefanHoutzager

@StefanHoutzager do you not see field level error messages on incorrect inputs?

zackurben avatar Mar 30 '17 14:03 zackurben

Yes I see them, that's is not what my isssue is about. For that see the first description.

StefanHoutzager avatar Mar 30 '17 15:03 StefanHoutzager

@StefanHoutzager okay, if you see field level messages and the submit button is disabled, what do you want to happen when clicking the disabled submit button?

Are new error messages/notifications created and where are they shown?

zackurben avatar Mar 30 '17 15:03 zackurben

I like the https://github.com/1000hz/bootstrap-validator functionality (try it if you're interested). When you click on the submitbutton with that validator you see the error messages for single field validations just like all of them would have been on blur of the field on which the validation was defined.

StefanHoutzager avatar Mar 30 '17 15:03 StefanHoutzager

@StefanHoutzager, gotcha. Seems like a pretty cool idea, I'll float it by the team, thanks!

zackurben avatar Mar 30 '17 15:03 zackurben

@StefanHoutzager / @zackurben I ran into this same issue. If this is the same issue that is caused by error messages displayed on "focus out" of the input (pushing the submit button out of range of the click), I was able to resolve this by adding a delay on the help-block display. In the Validator.prototype.showErrors function, I wrapped the $block DOM manipulation with a timeout:

        window.setTimeout(function () {
            $block.empty().append(errors);
        }, 100);

tridnguyen avatar Aug 09 '17 21:08 tridnguyen