make mandatory field

How to make actual time field mandatory in script?? Any examples with code??
http://www.trackstudio.ru/forum/
http://www.trackstudio.ru/forum/make-mandatory-field-issue-6377.html
if (message.getTime() == null || message.getTime() <= 0) {
throw new UserException("Please fill the spent time field.");
}