a validator script for data validation when form submit