I am trying to show some login validation errors using the code below but it's not working.
When i click on Login button it's going to the next page and error messages are not displayed as supposed.
Any ideas?
index.html:-
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<script type="lib/angular.min.js"></script>
<script type="angularFile.js"></script>
</head>
<body ng-app="demoApp" ng-controller="Ctrl">
<h1>Login Form</h1>
<form action="next.html" ng-submit="fun1($event)">
userName:<input name="name" ng-model="un">
<div style="color: red">{{msg1}}</div><br>
passWord:<input type="password" name="pwd" ng-model="pw">
<div style="color: red">{{msg2}}</div><br>
<input type="submit" value="Login"/>
</body>
</html>
angularFile.js:
var app = angular.modul("demoApp",[]);
app.controller("Ctrl",function($scope){
$scope.un="";
$scope.pw="";
$scope.msg1="";
$scope.msg2="";
$scope.fun1=function(e){
if($scope.un.leggth==0){
$scope.msg1="please enter user name"
e.preventDefault();
}else{
$scope.msg1="";
}
if($scope.pw.leggth==0){
$scope.msg2="please enter password"
e.preventDefault();
}else{
$scope.msg2="";
}
}
});
lengthinsteadleggthmodule.