How to to implement validation for input:
That if there is no @
so it's a name. and should be a minimum of 3 characters.
And if there have @
- so it's a Email. and he must to be a valid Email
I'm trying to think of a way how to do it and I can not find
I want to show the errors based on
ie: If no @
- error would be only for a minimum characters
And if there @
- Error will be for a valid email
<input type="email"
ng-model="string"
[name="string"]
[required="string"]
[ng-required="string"]
[ng-minlength="number"]
[ng-maxlength="number"]
[pattern="string"]
[ng-pattern="string"]
[ng-change="string"]>
<input name="email" type="email" ng-model="obj.email" ng-pattern="/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/" required>
There is excellent documentation + examples are provided on AngularJs official site.
Check input directive and customize them according to your need:
<input
ng-model="string"
[name="string"]
[required="string"]
[ng-required="boolean"]
[ng-minlength="number"]
[ng-maxlength="number"]
[ng-pattern="string"]
[ng-change="string"]
[ng-trim="boolean"]>
...
</input>
For input[email]
<input type="email"
ng-model="string"
[name="string"]
[required="string"]
[ng-required="string"]
[ng-minlength="number"]
[ng-maxlength="number"]
[pattern="string"]
[ng-pattern="string"]
[ng-change="string"]>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.