Fixed javascript error when using add form