0

In the registration form i have single field for both email and mobile number but it doesn't working properly.

<form name="regForm" >
<md-input-container flex md-no-float>
   <input ng-model="vm.form.email" type="text" placeholder="Email or Phone" translate translate-attr-placeholder="REGISTER.EMAIL" name="email or phone" ng-pattern="/^([_a-z0-9]+(\.[_a-z0-9]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,5}))|\d+$/"  required="true">
   <div ng-messages="regForm.email.$error" ng-show="regForm.email.$touched">
     <div ng-message="required">This field is required</div>
     <div ng-message="email">Your email address is invalid</div>
   </div>
</md-input-container>
</form>

Below code showing schema in model file

userModel.js

var UserSchema = new Schema({
   name: String,
   email: {type: String, required: true, select: true},
   password: {type: String, required: true, select: true},
});
3
  • ng-show= is duplicated Commented Apr 22, 2016 at 6:28
  • actually i am not getting how to do for both in single field. Could you please help me? Commented Apr 22, 2016 at 6:42
  • do you mean validating the field for email or phone number? Commented Apr 22, 2016 at 7:37

1 Answer 1

2

The field you're trying to reference in ng-messages and ng-show does not exist (there is no input with name="email" within the regForm).

For what you are trying to achieve I'd use custom validation logic like here. You might even use a custom validator as described in the docs.

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.