How do I check a variable for a number and an operator in an if statement in Javascript
<pre><code> &lt;html&gt;
&lt;head&gt;
&lt;title&gt; Buttons&lt;/title&gt;
&lt;style type="text/css"&gt;

.intro{background-color:;}
.duction{background-color:blue;}
.function{background-color:grey;}
.equals{background-color:orange;}
&lt;/style&gt;





&lt;/head&gt;
&lt;body&gt;
&lt;form name="calculator"&gt;
&lt;input type="text"  name="display" length="50" width="100"&gt;
&lt;div&gt;
&lt;input type= "button" value="7" class="intro" id="7" onclick="one(7)"&gt;&lt;/button&gt;
&lt;input type= "button" value="8" class="intro" id="8" onclick="one(8)"&gt;&lt;/button&gt;
&lt;input type= "button" value="9" class="intro" id="9" onclick="one(9)"&gt;&lt;/button&gt;
&lt;input type= "button" value="+" class="intro" id="+" onclick="Operate(+)"&gt;&lt;/button&gt;
&lt;input type= "button" value="-" class="intro" id="-" onclick="Operate(-)"&gt;&lt;/button&gt;
&lt;div&gt;
&lt;input type= "button" value="4" class="intro" id="4" onclick="one(4)"&gt;&lt;/button&gt;
&lt;input type= "button" value="5" class="intro" id="5" onclick="one(5)"&gt;&lt;/button&gt;
&lt;input type= "button" value="6" class="intro" id="6" onclick="one(6)"&gt;&lt;/button&gt;
&lt;input type= "button" value="x" class="intro" id="x" onclick="Operate(*)"&gt;&lt;/button&gt;
&lt;input type= "button" value="/" class="intro" id="/" onclick="Operate(/)"&gt;&lt;/button&gt;
&lt;div&gt;
&lt;input type= "button" value="1" class="intro" id="1" onclick="one(1)"&gt;&lt;/button&gt;
&lt;input type= "button" value="2" class="intro" id="2" onclick="one(2)"&gt;&lt;/button&gt;
&lt;input type= "button" value="3" class="intro" id="3" onclick="one(3)"&gt;&lt;/button&gt;
&lt;input type= "button" value="=" class="intro" id="=" onclick="Evaluate()"&gt;&lt;/button&gt;
&lt;div&gt;
&lt;input type= "button" value="0" class="intro" id="0" onclick="one(0)"&gt;&lt;/button&gt;
&lt;input type= "button" value="." class="intro" id="." onclick="one(.)"&gt;&lt;/button&gt;
&lt;input type= "button" value="c" class="intro" onclick="clearDigit()"&gt;&lt;/button&gt;

&lt;script type="text/javascript" src="C:\Users\LS\Desktop\QBJS\button.js"&gt;



&lt;/script&gt;



&lt;/body&gt;
&lt;/html&gt;

 var timer;
 var object;
 var thing;
 var digit="";
 var result;


 function one(event)
{
  clearTimeout(timer);
   timer=setTimeout(function(){AddDigit(event);},200);

}
</code></pre>

<p>My Operator buttons(+-/x) pass the operator to "x" and of course my number buttons pass 
numbers to "x". So I am trying to figure out how to check for numbers and operators in the 
the if statement below so that the parameters can be passed to document.calculator.display.value</p>

<pre><code>function AddDigit(x)
{
if (x == ????)

 {document.calculator.display.value=x;}
else
   {document.calculator.display.value+=digit + x;}
}



function Evaluate()
{
  result=eval(document.calculator.display.value);
   document.calculator.display.value = result;
}
</code></pre>

<p>I'm also trying to figure out a way to swap the text between two buttons after they have been "highlighted" with a className change to "duction". (this question is totally unrelated to the first</p>

<pre><code>document.ondblclick=function(button)
{
  clearTimeout(timer);

  thing=button.target;

if(thing.className=="intro")
  {thing.className="duction";}

else if(thing.className=="duction")
  {thing.className="intro";}    
}



function clearDigit()
{
  document.calculator.display.value="";
}
</code></pre>
