I want to validate the fields. When user doesn't enter anything in the field and click on submit button, could not able to validate it.
Please see the sample below:
$scope.validateFields = function(){
alert("Comments " + $scope.comments); //When fields are blank and click on submit, it shows undefined
if($scope.comments === 'undefined'){
alert("comments are blank");//not printed
$scope.comments = 'undefined';
}
if( $scope.comments.length == 0){
alert("comments length is zero"); //not printed
$scope.comments = 'undefined';
}
In the above sample code, when click on submit button without entering anything in the comments fields, it is not entering the if condition. I want to assign $scope.comments='undefined'
when the comments field is blank and clicked on submit button.