JSFiddle - React, Tailwind, and code Playground
by kapilgopinath
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.5/angular.min.js"></script>
<div ng-app="main">
<div ng-controller="mainController">
<input ng-model="userInput">
<input type="submit" ng-click="submit()">
<p ng-show="err">{{err}}</p>
</div>
</div>
<select>
<option>Active Portfolio 🛈</option>
</select>
JavaScript
angular.module("main", [])
.controller("mainController", function($scope) {
$scope.submit = function() {
$scope.userInput = $scope.trim($scope.userInput);
console.log($scope.userInput);
}
$scope.trim = function() {
var userInput = "£1234";
if (userInput.indexOf("£") == 0) {
userInput = userInput.substr(1);
userInput *= 100;
}
//Check if userInput is not a number
if (isNaN(userInput)) {
$scope.err = "you have entered an invalid character";
return -1;
} else {
return userInput;
}
}
});