Are You Passed the values via Page...?
If you pass the values via page then check the condition using "if".
if(field1!=field2 && field1!= field3 && field1 != field4 && field2 != field3 && field2 != field4 && field3!= field4)
{
}
i'm not sure this is your expecting but as per my understanding i given this solution .