You need to sign in to do that
Don't have an account?
Niraj Singh 28
set validity not working on lightning component
Hello All,
I have needed to modify validity value of an input but not getting modified after setting this value. Please have a look on my code suggest what i am doing wrong here.
IsValid:function(cmp,evt,helper){
var contactFields=cmp.find("contactField");
var blank=0;
blank++;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(contactFields.length != undefined){
var allvalid=contactFields.reduce(function(validSoFar,inputCmp){
inputCmp.showHelpMessageIfInvalid();
if(inputCmp.get("v.name")=='VSMemail'){
var conEmail=inputCmp.get("v.VSMemail");
if(reg.test(conEmail) == false)
{
inputCmp.set('v.validity', {valid:false, badInput :true});
}
}
return validSoFar && inputCmp.get("v.validity").valid;
},true);
return allvalid;
}
I have needed to modify validity value of an input but not getting modified after setting this value. Please have a look on my code suggest what i am doing wrong here.
IsValid:function(cmp,evt,helper){
var contactFields=cmp.find("contactField");
var blank=0;
blank++;
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(contactFields.length != undefined){
var allvalid=contactFields.reduce(function(validSoFar,inputCmp){
inputCmp.showHelpMessageIfInvalid();
if(inputCmp.get("v.name")=='VSMemail'){
var conEmail=inputCmp.get("v.VSMemail");
if(reg.test(conEmail) == false)
{
inputCmp.set('v.validity', {valid:false, badInput :true});
}
}
return validSoFar && inputCmp.get("v.validity").valid;
},true);
return allvalid;
}