Validate multiple fields On Add

Validate multiple fields On Add

I have a form with 3 fields. I want to validate the when submittng the form, that the record does not contain either field. 

For example:

if (count(team_member[name == input.name]) > 0)
{
alert "Name already exists";
cancel submit;
}

will only check if the if name is used. I want to check both name and another field. Tried this but no luck.

if (count(team_member[firstname == input.firstname]) > 0) &&  (count(team_member[lastname == input.lastname]) > 0)
{
alert "We found a potentially duplicate record";
cancel submit;
}