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

AngularJS Login Form with Validation

This document provides an AngularJS program for creating a login form with validation for username and password fields. The form requires both fields to be filled, and upon submission, it checks if the credentials match predefined values. If the login is successful, an alert is shown; otherwise, a failure message is displayed.

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)
3 views2 pages

AngularJS Login Form with Validation

This document provides an AngularJS program for creating a login form with validation for username and password fields. The form requires both fields to be filled, and upon submission, it checks if the credentials match predefined values. If the login is successful, an alert is shown; otherwise, a failure message is displayed.

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

8.

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


username and password fields.

<html ng-app="loginApp">
<script
src="[Link]
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 = [Link]('loginApp', []);
[Link]('loginController',
function ($scope) {
$[Link] = function () {

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


if ($[Link] == 'ram' && $[Link]
== '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