JS runtime error when viewing the form