Conditionally mandatory field

Conditionally mandatory field

Hi, i have a problem with On Add/Validate. I'm doing quite simple form (few fields hide on load, few condition for fields to show on user input - every condition on the same dropdown field) to my company contact site. But i'm trying to do one of on load hidden fields as mandatory if there were be executed condition for showing that field. Below i'm pasting my Validate code, can someone tell me what's wrong with it?

I read lots of posts on this forum and i can't see differences between my code and code written by other people. Sorry for my english.

  1. if input.kategoria = "Anulacja zamówienia" && input.NrGK = null
  2. {
  3.       alert "Wpisz nr GK aby anulować zamówienie.";
  4.       cancel submit;
  5. }