I have an html form that has several textboxes (<input type="text"
. What I want to do is to allow users to enter numbers and number equations like +, -, /, and * into the textbox, and display the result on the textbox. For example, user will enter "200 / 4" and the form will display "50".
When onblur event happens, I do an eval on the content of the textbox, forcing the calculation of the contents of the textbox. I then replace the contents of the textbox with the result from eval. It works fine if I enter "200 / 4" or "200". "200 / 4" gives me "50", "200" gives me "200". However, when I enter "0200", I am getting "128". It seems like the problem happens if the number entered starts with "0".
Could someone englighten me on this?
Thanks in advance.
When onblur event happens, I do an eval on the content of the textbox, forcing the calculation of the contents of the textbox. I then replace the contents of the textbox with the result from eval. It works fine if I enter "200 / 4" or "200". "200 / 4" gives me "50", "200" gives me "200". However, when I enter "0200", I am getting "128". It seems like the problem happens if the number entered starts with "0".
Could someone englighten me on this?
Thanks in advance.