Can this validation function be called from JS?