I'm working on an AngularJS calculator project and I'm struggling to limit the decimal point to only one when performing calculations. Currently, clicking the "." button in the calculator results in two dots appearing, which is not valid for decimal operations. Below is the code snippet I attempted to use to validate the decimal point input. Additionally, if anyone has suggestions on how to make the "ac" button/function work as intended, it would be greatly appreciated.
if(otpt.indexOf('.') == -1) {
$scope.zeroflag = false;
} else {
$scope.zeroflag = true;
}
Despite several attempts, I have yet to find a solution to this issue.
For reference, here is my complete calculator program on CodePen: AngularJS calculator
... (The rest of the code remains untouched for clarity) ...