<html>
<head>
<meta charset="windows-1251">
</head>
<body>
<input type="text" value="10+sin(1)" id="a">
<input type="button" value="запуск" OnClick="zap()">
<script>
function zap(){
var a=document.querySelector("#a").value
var test=function(){
var re=/\s*(\d+)\s*([-+*\/])\s*(cos|sin)\s*\(\s*(\d+)\s*\)\s*/i
if(!re.test(a)) return alert ("NO valid data")
var expr=a.match(re),
dig=(+expr[1]),
operator=expr[2],
resultOfFunc=Math[expr[3]](+expr[4]),
result=dig+operator+resultOfFunc
return eval(result)
}
alert (test())
}
</script>
</body>
</html>