js validations and alert handling