Making a field required - code not working

Making a field required - code not working

I'm trying to make a field required if the check box above it is checked.  This is the code I've input, but it comes back with an error.

((input.VAT_registered == "yes")  &&  (input.VAT_number == ""))
{
alert "Please enter VAT number";
cancel submit;

Please help!

Thanks