public class PhoneValidationC {
public Account acc {get;set;}
public PhoneValidationC(){
acc = new Account();
}
public pageReference insertIt(){
System.debug('Apex Method');
INSERT acc;
return null;
}
}
public class PhoneAccValC {
public String phone {get;set;}
public List<Account> acc {get;set;}
public PhoneAccValC() {
acc = [SELECT Id, Name, Phone FROM Account LIMIT 1];
}
public PageReference validate() {
if(phone.length() == 10) {
acc[0].phone=phone;
UPDATE acc[0];
}
else{
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Enter Valid Phone Number');
ApexPages.addMessage(msg);
return null;
}
return null;
}
}
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Greetings to you!
Please try the below code, I have tested in my org and it is working fine. Kindly modify the code as per your requirement.
Visualforce:
Controller:
OR
Visualforce:
Controller:
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas