I would like to allow user to perform simple calculations in the text inputs, so that typing 2*5 will result in 10. I'm replacing everything but digits with an empty string and then make calculation using eval(). This seems easier and probably faster then parsing it manually.
It's often being said that eval() is unsafe, so I would like to hear is there any danger or drawback of using it in this situation.
function (input) {
value = input.value.replace(/[^-\d/*+.]/g, '');
input.value=eval(value);
}