modal validation and insert in db