Find out if course register is already registered

Find out if course register is already registered

Hello, I have a form for a course registration with a field of Delegate_ID. I want that field when entered to check whether the Delegate_ID is already registered against the Delegate Registration form (report). I have tried this but it doesn't work... Looking for some guidance:

check_id = Delegate_Registration [ Delegate_ID == input.Delegate_ID ];

if (Delegate_ID.count == 0)

{

alert "Please register first ";

}