I initiated an angular + laravel project yesterday, but I encountered an error in angular which has halted my progress.
Below is the code snippet:
<div class="form-group" ng-controller="CheckPawd">
<label>Current Password</label>
<input type="text" name="cpwd" ng-model="cpwd" ng-keyup="checkerPwd()" class="form-control" placeholder="Enter Current Password" required>
<p class="invalid" ng-show="!pwdChnge.cpwd.$pristine && pwdChnge.cpwd.$error.required">⇧ Current Password is required</p>
<p class="invalid" ng-show="checker">⇧ Current Password is not matching</p>
</div>
Angular Controller:
app.controller('CheckPawd',function($scope,$http){
$scope.checkerPwd = function(){
$http({
method:'post',
url:'checkPwd',
data:$.param({pwdd:$scope.cpwd})
}).success(function (data,response){
console.log(data);
if(data=="1"){
$scope.checker=null;
}else{
$scope.checker = data;
}
});
};
});
Laravel Function:
public function checkPwd()
{
if(Hash::check(Input::get('pwdd'), Auth::user()->password))
{
return 1;
}else{
return 0;
}
}
This segment is related to the password change feature. There are three fields in total:
Current password, New password, Confirm New Password
During the entry of the current password, I aim to validate it using an API.
How can I implement custom validation rules? The current code does not allow me to disable the submit button upon encountering an error in the API response.
Any suggestions on resolving this issue?