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?

  • 2
    please include the relevant code from your link – glls Feb 11 '19 at 16:09
  • good point, added – Bobbygllh Feb 11 '19 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.