Thank you @Henry Wright and @danbp, these snippets are very useful. There is one more question about the validations, what if I want to stop the process right the way and show an error message accordingly to the user when the length of field exceeds the max length specified. Is it possible to do that inside the code snippets above?