I want to check for duplicates when inserting a new contact in my database, then showing a msg that the contact is already in the db.
this is what i've done:
function isDuplicate(names,phone,email,adresa){
var isduplicate=false;
for(var i=0;i<addresslist.length; i++){
if(addresslist[i].names.toLowerCase()==names.toLowerCase()
&& addresslist[i].phone.toLowerCase()==phone.toLowerCase()&&
addresslist[i].email.toLowerCase()==email.toLowerCase()&&
addresslist[i].adresa.toLowerCase()==adresa.toLowerCase()
){
isduplicate=true;
}
}
return isduplicate;
}
later
if(isDuplicate(name,phone,email,adresa)){
$('#notice').empty().html('Kontakti ndodhet tashme ne databaze').show('slow');
}
and also i want to check that the phone form has only numbers.
if(isNaN(new Number(phone))){
$('#notice').empty().html('Telefoni duhet te kete vetem vlera te vlefshme numerike').show('slow');
}
is thi code ok?