Question: I have 2 input boxes for first name and last name of passengers travelling.  

There could be maximum 9 number of passengers.  

It is not allowed to have two passengers with same name(first and last combined)
How can I check if none of the passenger have same names(first and last name combined)

```
<input type="text" name="adultFirstName1" id="adultFirstName1" class="form-control input-sm" placeholder="" style="width:100%; padding:5px;">

```

Thanks.

**Edit:** 

I am not using a database to store the passenger names and the passengers are all entered on the same page.

Answer: 
```
var name=[];    
var sameName=false;
for(var i=1;i<=<%=detailsModel.getNumberOfAdult()%>;i++)
 {
var fullName = document.getElementById("adultFirstName"+i).value+" "+document.getElementById("adultLastName"+i).value
name.push(fullName);
}
for(var i=1;i<=<%=detailsModel.getNumberOfChild()%>;i++)
{
var fullName = document.getElementById("childFirstName"+i).value+" "+document.getElementById("childLastName"+i).value
name.push(fullName);

}
for(var i=1;i<=<%=detailsModel.getNumberOfInfant()%>;i++)
{
var fullName = document.getElementById("infantFirstName"+i).value+" "+document.getElementById("infantLastName"+i).value
name.push(fullName);
}
for(var i=0;i<name.length;i++)
{
for(var j=i+1;j<name.length;j++)
    {
    if(name[i]==name[j])
    {
        var sameName=true
        valid= false;
    }

  }
}
if(sameName==true)
    {
    $('#sameNameError').html('2 Passengers Cannot Have Same Name');
    }
else
    {
    $('#sameNameError').html('');
    }

```
Are there 2 input boxes for each passenger? If so, try something like this: 

```
$(document).ready(function(){
    $("button").click(function(){
        if($("#adultFirstName1").val() == $("#adultFirstName2").val() 
            && $("#adultLastName1").val() == $("#adultLastName2").val()) {

            //Names are the same

        }
    });
});

```

Or are you needing to check against the names of other passengers already in a database somewhere?