You need to sign in to do that
Don't have an account?

Validation in Trigger
How can i validate mobile number should be 10 digit in trigger.I have created a trigger but its not working
trigger MobileNumber on Account (before update,before insert) { if( Trigger.isbefore && Trigger.isInsert) { for(Account l: Trigger.New){ if(l.Mobile__c!=null && Mobile__c.lenght()=10){ alert ("Error"); } } } }
LEN(Mobile__c) < 10
For triggers correct the if statement
if(l.Mobile__c!=null && l.Mobile__c.length() !=10){
l.adderror('Mobile number should be of length 10');
}
Kindly mark it as resolved.
String numberWithoutSpclChars = phoneNumber.replaceAll('[^\\d]','');
phoneNumber = numberWithoutSpclChars;
if(phoneNumber.isNumeric())
{
if(phoneNumber.length() >= 10)
{
isValidNumber = true;
}
}