Created
August 8, 2019 17:38
-
-
Save sudikrt/2dc597eb74d5adb2879ac4df3b4ac68b to your computer and use it in GitHub Desktop.
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
validateEmail : function(component, event, helper) { | |
var id = event.getSource().getLocalId(); | |
var emailInp = component.find(id); | |
var value = emailInp.get("v.value"); | |
var patt = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
var res = patt.test(value); | |
var saveBtn = component.find("saveBtn"); | |
// Is input an email? | |
if (value != "" && res == false) { | |
// Set error | |
emailInp.set("v.errors", [{message:"Invalid Email Address"}]); | |
saveBtn.set("v.disabled", true); | |
} else { | |
// Clear error | |
emailInp.set("v.errors", null); | |
saveBtn.set("v.disabled", false); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment