Im trying to create a visualforce page and do some validations on it. If my first name and last name are same then it should throw me an error ..or else it should insert the record.When i tried running the code,its giving me this error even though I'm entering "Last Name". Could someone figure this out?
public class perinfo {
public contact Cont {get;set;}
public String fname {get;set;}
public String lname {get;set;}
public String email {get;set;}
public String phone {get;set;}
public perinfo() {
fname = '';
lname = '';
email = '';
Cont = new Contact();
}
public void Submitbutton() {
if (fname == lname)
apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.error, 'FirstName and LastName cannot be same'));
else
insert cont;
}
}