I think I'd make this line a helper function (yes, it would have to be global) and call it from the 3 places where you are currently hard-codding "Required field." I don't like having the same string and logic appearing multiple places.