formError function