Adding Errors with JS

after the error i want to stop the button action sequence flow can anyone help me in this?