Math Field
Sometimes you want to require the user to enter a number. Sometimes that number needs to be calculated by the user. They could use a calculator, or you could provide them with a text field capable of performing simple math operations.
Download
Click Here to download the math field script. The instructions for use are in the script file.
Example
This is an example of the script in action. This text field will perform simple math operations. Type a number and then type '+', '-', '*', or '/'. After typing the operation, type another number. You may then type another operation to continue doing math or type '=' to finish your calculation.
HTML
The following is the HTML code that produces the above example. The parts that give the text field math capability are in red.
<script src="mathField.js" language="javascript"></script> <form action=""> Number: <input onkeyup="javascript:mathFieldKeyUp(this, 2, 2)" type="text"> </form>











