For this you have to write JS code in script task and for validation you can use tw.system.addCoachValidationError("controlid","Error to be shown");. and on submit first run the server script and attach a exclusive event also to check if it is not valid then use stay on page intermeddiate event otherwise go to next activity.