Angular Input Validation While Loops Javascript