0% found this document useful (0 votes)
10 views2 pages

Angular 8th Program

Uploaded by

Abhishes Sah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

Angular 8th Program

Uploaded by

Abhishes Sah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

8.

DevelopAngularJS program to create a login form, with validation for the


username and password fields.

<html ng-app="loginApp">
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></
script>

<body ng-controller="loginController">
<h1>Login Form</h1>

<!-- Form for login with validation -->


<form ng-
submit="lo
gin()">
Username
<input type="text" ng-model="username" required>
<
b
r
>

P
a
s
s
w
o
r
d
<input type="password" ng-model="password" required>
<br>
<button type="submit">Login</button>
</form>

<script>
var app = angular.module('loginApp', []);
app.controller('loginController',
function ($scope) {
$scope.login = function () {

// Check if username is "Ram" and password is "Ram"


if ($scope.username == 'ram' && $scope.password
== 'ram') { alert('Login successful');
// Add further logic for successful login
} else {

alert('Login failed. Invalid username or password.');


// Add logic for failed login

}
};
});
</script>

</body>
</html>

Sample Output:

You might also like