added validation function before forms are updated or inserted.