create js code only if needed (if respective min/max set)

fixes also problem with empty min/max field
cleanup
cleanup, comments
problem 1999, real dateformat