Created
July 2, 2018 23:27
-
-
Save SalesforceBobLightning/ff3d895b9c0f15135267107d812bbcc8 to your computer and use it in GitHub Desktop.
Salesforce Lightning JavaScript Helper method for validating form 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
| validateFields : function(cmp, event, helper){ | |
| var isValid = true; | |
| var fields = []; | |
| fields = cmp.find("field"); | |
| for (var i = 0; i < fields.length; i++) { | |
| if (fields[i] != null){ | |
| if (fields[i].get('v.validity').valid == false){ | |
| fields[i].showHelpMessageIfInvalid(); | |
| isValid = false; | |
| } | |
| } | |
| } | |
| return isValid; | |
| }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment