TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
piu bhosale
NA
31
873
validation in angular js mvc asp.net-validation on page load
Sep 19 2018 7:55 AM
angular.module('myApp').controller('Part3Controller', function ($scope, LoginService) {
$scope.Submited = false;
$scope.msg = "";
$scope.IsLoggedIn = false;
$scope.IsFormValid = false;
//initilize user data object
$scope.LoginData = {
UserName: '',
Password:''
}
//Check whether the form is valid or not using $watch
$scope.$watch("myForm.$valid", function (TrueOrFalse) {
$scope.IsFormValid = TrueOrFalse; //returns true if form valid
});
$scope.Login = function () {
$scope.Submited = true;
if ($scope.IsFormValid) {
LoginService.getUserDetails($scope.LoginData).then(function (d) {
debugger;
if (d.data.UserName != null) {
debugger;
$scope.IsLoggedIn = true;
$scope.msg = "You successfully Loggedin Mr/Ms " +d.data.FullName;
}
else {
alert("Invalid credentials buddy! try again");
}
});
}
}
})
.factory("LoginService", function ($http) {
//initilize factory object.
var fact = {};
fact.getUserDetails = function (d) {
return $http({
url: '/Data/Userlogin',
method: 'POST',
data:JSON.stringify(d),
headers: { 'content-type': 'application/json' }
});
};
return fact;
});
when i run application, validation shows on page load only.
i want validation after clicking login button.
please help me.
Attachment:
.cshtml_code.rar
Reply
Answers (
0
)
how to pass list and Images through Ajax in MVC
connectivity of mvc with database with the help of adodotnet