I am trying to show javascript popup error message when processing form inputs.But i cant figure it correctly.Here is my html file
<form name="form" ng-app ng-submit="register(user)">
<div class="controls">
<input type="email" name="email" ng-model="user.email" required />
<span class="help-inline" ng-show="submitted && form.email.$error.required">Required</span>
<span class="help-inline" ng-show="submitted && form.email.$error.email">Invalid email</span>
</div>
<div class="controls">
<input type="text" name="name" ng-model="user.name" required />
<span class="help-inline" ng-show="submitted && form.name.$error.required">Required</span>
<span class="help-inline" ng-show="submitted && form.name.$error.email">Invalid email</span>
</div>
</form>
In my controller i want to populate javascript popup error message.Here is my controller
angular.module('starter.controllers',[])
.controller('DashCtrl', function($scope) {
$scope.register=function(user){
//this will work
alert(user.email)
//this wont work
if(user.email=="")
alert("Email required");
}
})
Thanks in advance.
type="email"the model will not be populated unless the input field actually contains a valid email, souser.emailwill beundefinedand not"".