combined all event handlers into one
refactor to create a library
clean and works too
added validation type 'confirm'
fixed message in email confirmation of JSON