"angularjs application to check palindrome"
Bootstrap 3.0.0 Snippet by akhtarvahid

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> </head> <body> <div ng-app="myApp" ng-controller="myCtrl"> <div class="container"> <div class="form-group"> <label for="usr">Enter Number:</label> <input type="text" class="form-control" id="usr" ng-model="prime"> <input type="button" ng-click="check()" value="check"> </div> <h1>You entered: {{prime}}</h1> <h1>You entered: {{message}}</h1> </div> <script> var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { var str=''; $scope.check=function(){ check_Palindrome($scope.prime); } function check_Palindrome(str_entry){ var cstr = str_entry.toLowerCase().replace(/[^a-zA-Z0-9]+/g,''); var ccount = 0; if(cstr==="") { alert("Nothing found!"); return false; } if ((cstr.length) % 2 === 0) { ccount = (cstr.length) / 2; } else { if (cstr.length === 1) { alert("Entry is a palindrome."); return true; } else { ccount = (cstr.length - 1) / 2; } } for (var x = 0; x < ccount; x++) { if (cstr[x] != cstr.slice(-1-x)[0]) { $scope.message="The entry isn't is a palindrome."; return false; } } $scope.message="The entry is a palindrome."; return true; } }); </script> <p>Change the name inside the input field, and you will see the name in the header changes accordingly.</p> </body> </html>

Related: See More


Questions / Comments: