Last active
          October 14, 2019 16:48 
        
      - 
      
 - 
        
Save srujan21/754e0ce2f168bb3910f896501b8e2d13 to your computer and use it in GitHub Desktop.  
    Validating form fields on Lightning Aura component 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var page1ReqFields = ['lastName','firstName','prefix','birthDate','gender','homePhnNum','pmAddres','pmCity','pmState','pmZip']; | |
| // aura Ids of required fields | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* Validate required fields */ | |
| validateReqFields: function(component, event,ReqFields) { | |
| component.set('v.validateReqFields',false); | |
| var i; | |
| for(i in ReqFields){ | |
| var value = component.find(ReqFields[i]).get("v.value"); | |
| var validityVal = component.find(ReqFields[i]).get("v.validity").valid; | |
| if((value == "" || value == null ) && validityVal != true){ | |
| component.find(ReqFields[i]).reportValidity(); | |
| component.set('v.validateReqFields',true); | |
| component.set('v.dispReqFieldError',true); | |
| console.log('dispReqFieldError',component.get('v.dispReqFieldError')); | |
| } | |
| } | |
| window.scrollTo(0, 0); | |
| }, | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment