Having some trouble validating an Aura component field (it allows lookup in Flow) as i can't seem to think of how to fire an onclick event from the standard Next button (in flow). I would use the onclick event to validate whether the field was empty or not.

I am using lightning:recordEditForm and lightning:input field in my Aura component. I am trying to integrate the validation mentioned in this link

    <lightning:input aura:id="field" label="First name" placeholder="First name" required="true" />
    <lightning:input aura:id="field" label="Last name" placeholder="Last name" required="true" />        
    <lightning:button aura:id="submit" type="submit" label="Submit" onclick="{! c.onClick }" />

onClick: function (cmp, evt, helper) {
    var allValid = cmp.find('field').reduce(function (validSoFar, inputCmp) {
        return validSoFar && inputCmp.get('v.validity').valid;
     }, true);
     if (allValid) {
         alert('All form entries look valid. Ready to submit!');
     } else {
         alert('Please update the invalid form entries and try again.');


As you can see this example requires a Submit button in order to fire the validation (which makes sense). Does anyone have any ideas on how i would access the Next button in the flow in order to add an onclick event?

New contributor
Bobbygllh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 2
    please include the relevant code from your link – glls Feb 11 at 16:09
  • good point, added – Bobbygllh Feb 11 at 16:26

Your Answer

Bobbygllh is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.