1

I have inputs with dynamically assigned names. As a result I have input names like

name="Athlete/Guardian_firstName"

For inputs it's fine, but validation doesn't work since this record

medForm.Athlete/Guardian_firstName.$invalid

is invalid for angular's ng-class due to the slash "/". (medForm is form's name). Are there any other way to access inputs from form in angular, so inputs with any special characters will work?

<div class="form-group" ng-class="{ 'has-error': medForm.Athlete/Guardian_firstName.$invalid }">
  <label for="firstName" class="col-md-3 control-label">First Name</label>
  <div class="col-md-9">
    <input type="text" class="form-control" id="firstName" name="Athlete/Guardian_firstName" required ng-model="firstName">
  </div>
</div>

1 Answer 1

5

Try this way:

medForm['Athlete/Guardian_firstName'].$invalid
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.