Fill field if null

Fill field if null

I have a form with a with alpha-numeric entry (student_id) which must be unique.  If it is entered, I want it to go to the next field.  If it is not, I want to fill it with a generated entry (student_id_temp).  I am using the MaxValueHolder form to generate a this student_id_temp by adding the number generated to a string.

Question:  How do I do the "if" statement?  if student_id is null then get generated student_id_temp?  (I would like it to run on input for the field rather than validate at the end of the form, but not absolutely necessary)

Thanks!
RAS