Hello. I am trying to create a way so that user's must enter their password twice on signup, and it will check to see if the passwords match, live.
I keep getting the error: Reference error: 'function' is not defined where function is the name of my function...
Here is my HTML:
<input type="password" class="form-control" placeholder="Password..." id="password" ng-model="password" required>
<input type="password" class="form-control" placeholder="Confirm password..." id="confirm_password" ng-model="PasswordConfirm" onkeyup="checkPass(); return false;" required>
<span id="confirmMessage" class="confirmMessage"></span>
controllers.js:
wimControllers.controller('SignupController', [ 'userService', '$scope', '$http', '$location', function (userService, $scope, $http, $location) {
function checkPass()
{
//Store the password field objects into variables ...
var pass1 = document.getElementById('password');
var pass2 = document.getElementById('confirm_password');
//Store the Confimation Message Object ...
var message = document.getElementById('confirmMessage');
//Set the colors we will be using ...
var goodColor = "#66cc66";
var badColor = "#ff6666";
//Compare the values in the password field
//and the confirmation field
if(pass1.value == pass2.value){
//The passwords match.
//Set the color to the good color and inform
//the user that they have entered the correct password
pass2.style.backgroundColor = goodColor;
message.style.color = goodColor;
message.innerHTML = "Passwords Match!"
}else{
//The passwords do not match.
//Set the color to the bad color and
//notify the user.
pass2.style.backgroundColor = badColor;
message.style.color = badColor;
message.innerHTML = "Passwords Do Not Match!"
}
}
index.blade.php:
<html lang="en" ng-app="wim">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WIM(afy)</title>
<link href="bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="css/wimmain.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script src="bower_components/angular/angular.min.js"></script>
<script src="bower_components/ng-file-upload-shim/ng-file-upload-shim.min.js"></script>
<script src="bower_components/ng-file-upload/ng-file-upload.min.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<script src="bower_components/angular-route/angular-route.min.js"></script>
<script src="bower_components/angular-local-storage/dist/angular-local-storage.min.js"></script>
<script src="bower_components/restangular/dist/restangular.min.js"></script>
<script src = "js/app.js"></script>
<script src = "js/services.js"></script>
<script src = "js/controllers.js"></script>
<style>
li {
padding-bottom: 8px;
}
</style>
</head>
<body style="background-color: #ef5350;">
<div ng-view></div>
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>
I solved this. I extracted the checkPass function into it's own file and included that js file in my index.blade.php.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community