I have a question about my calculator. I want to ensure that if the input string contains "0", an error alert is displayed. However, I do not want to check for the "/" character. Below is the function I have written:
<input type="text" name="answer" id="t" onkeyup="isAllowedSymbol(this);checkLength(this);" placeholder="Enter data" >
<input type="button" value=" ÷ " onclick="calculator.answer.value += '/';div(this);checkLength(this);" />
function div(input)
{
var input = document.getElementById("t");
var lastElement = (input.value.length-1);
//alert(input.value.charAt(lastElement));
if (input.value.charAt(lastElement) == 'null')
{
alert(" / to Zero");
}
}