var a1= Number(document.form1.visota.value);
var a1= parseInt(document.form1.visota.value);
var a1= parseFloat(document.form1.visota.value);
<form name="form1"> <input type="text" onclick="this.style.backgroundColor = 'white';" name="visota" /><br/> <input type="text" onclick="this.style.backgroundColor = 'white';" name="shirina" /><br/> <input type="button" onclick="raschet(this.form)" value="Перемножить" /><br/> <input type="text" name="res_metall" /> </form> <script> function raschet(form){ var visota = form[0], shirina = form[1], error; if(isNaN(visota.value)) { visota.style.backgroundColor = 'red'; error = true; } if(isNaN(shirina.value)) { shirina.style.backgroundColor = 'red'; error = true; } if(error == true) return NaN; s = visota.value * shirina.value; form[3].value=s; return s; } </script>
<form name="form1"> <input type="text" onclick="this.style.backgroundColor = 'white';" name="visota" /><br/> <input type="text" onclick="this.style.backgroundColor = 'white';" name="shirina" /><br/> <input type="button" onclick="raschet(this.form)" value="Перемножить" /><br/> <input type="text" name="res_metall" /> </form> <script> function check(el){ if(isNaN(el.value)) { el.style.backgroundColor = 'red'; return false; } else return true; } function raschet(form){ var visota = form[0], shirina = form[1], checkResult = [check(visota), check(shirina)]; for(var i = 0; i < checkResult.length; i++) if(!checkResult[i]) return NaN; form[3].value=visota.value * shirina.value; } </script>
form[3].value=visota.value * shirina.value;