AngularJS Form Validation

Developer
Size
2,249 Kb
Views
36,432

How do I make an angularjs form validation?

What is a angularjs form validation? How do you make a angularjs form validation? This script and codes were developed by Fabio Biondi on 13 October 2022, Thursday.

AngularJS Form Validation Previews

AngularJS Form Validation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>AngularJS Form Validation</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <body ng-app ng-controller="LoginValidators" ng-class="{fullPageError: !myForm.$valid}"> <h2>AngularJS form and field validation</h2> <form name="myForm" class="jumbotron"> <!-- ALERT MSG --> <div class="alert alert-danger" ng-show="showAlert"> {{alertMsg}} <button class="btn btn-warning" ng-click="closeAlert()">x</button> </div> <!-- LOGIN PANEL --> <div ng-show="!showAlert"> <input type="text" name="user" ng-model="username" required placeholder="Username (required)" ng-class="{error: myForm.user.$invalid}"/><BR> <input type="password" name="pass" ng-model="password" required ng-minlength="5" placeholder="Password (min 5 chars)" ng-class="{error: myForm.pass.$invalid}" /><BR> <button class="btn btn-success" ng-click="send()" ng-disabled="myForm.$invalid">Send</button> </div> </form> <h4>Form $valid: {{myForm.$valid}}</h4> <h4>Form user $error: {{myForm.user.$error}}</h4> <h4>Form user $invalid: {{myForm.user.$invalid}}</h4> <h4>Form pass $error: {{myForm.pass.$error}}</h4> <script src="https://code.angularjs.org/1.2.6/angular.min.js"></script>
</body> <script src="js/index.js"></script>
</body>
</html>

AngularJS Form Validation - Script Codes CSS Codes

body
{ background-color: #0a8b00;
}
.fullPageError
{ background-color: #ff1500 !important;
}
.error
{ background-color: #ff1c37; color: #fff;
}

AngularJS Form Validation - Script Codes JS Codes

function LoginValidators($scope) { // hide Alert by default $scope.showAlert = false; $scope.send = function () { // Show Alert $scope.showAlert = true; // Custom Alert message $scope.alertMsg = $scope.username + " is now Logged"; } $scope.closeAlert = function () { $scope.showAlert = false; $scope.username = ""; $scope.password = ""; }
}
AngularJS Form Validation - Script Codes
AngularJS Form Validation - Script Codes
Home Page Home
Developer Fabio Biondi
Username fabiobiondi
Uploaded October 13, 2022
Rating 3
Size 2,249 Kb
Views 36,432
Do you need developer help for AngularJS Form Validation?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Fabio Biondi (fabiobiondi) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!