JavaScript validation issues + fixed invalid JSON