ruler1
MIS
- Feb 19, 2007
- 89
hope i am posting in the right place. i have a byte calculator which works fine appart from it eccepts any input. i was wondering if anyone knows of a way to stop it from eccepting anything other than numbers? here is the code i am using below.
<tr>
<td class="sect1" colspan="2"> <a name="gbottom"></a><span class="hlmain">Share Calculator<br />Convert Kib/Mib.. to Bytes</span></td>
<td class="sect1"><span class="postbody">
<input type="text" name="bytev" size="20" maxlength=11 value="enter value" onfocus="document.edithub.bytev.value=''">
<select size="1" name="units">
<option value="Bytes">Bytes</option>
<option value="Kib">Kib</option>
<option value="Mib">Mib</option>
<option value="Gib">Gib</option>
<option value="Tib">Tib</option>
<option value="Pib">Pib</option>
</select>
<input type="button" value="Calculate" name="B1" onClick="calculate()"><br />
<input type="text" name="output" size="25" maxlength="25" value="results here"> <--- this is the number you need
<script>
var bytevalue=0
function calculate(){
var invalue=document.edithub.bytev.value
var selectunit = document.edithub.units.options[document.edithub.units.selectedIndex].value
if (selectunit=="Bytes")
bytevalue=invalue
else if (selectunit=="Kib")
bytevalue=invalue*1024
else if (selectunit=="Mib")
bytevalue=invalue*1024*1024
else if (selectunit=="Gib")
bytevalue=invalue*1024*1024*1024
else if (selectunit=="Tib")
bytevalue=invalue*1024*1024*1024*1024
else if (selectunit=="Pib")
bytevalue=invalue*1024*1024*1024*1024*1024
document.edithub.output.value = bytevalue
}
</script></span></td>
</tr>
i'd be greatful for any help with this. thanks
<tr>
<td class="sect1" colspan="2"> <a name="gbottom"></a><span class="hlmain">Share Calculator<br />Convert Kib/Mib.. to Bytes</span></td>
<td class="sect1"><span class="postbody">
<input type="text" name="bytev" size="20" maxlength=11 value="enter value" onfocus="document.edithub.bytev.value=''">
<select size="1" name="units">
<option value="Bytes">Bytes</option>
<option value="Kib">Kib</option>
<option value="Mib">Mib</option>
<option value="Gib">Gib</option>
<option value="Tib">Tib</option>
<option value="Pib">Pib</option>
</select>
<input type="button" value="Calculate" name="B1" onClick="calculate()"><br />
<input type="text" name="output" size="25" maxlength="25" value="results here"> <--- this is the number you need
<script>
var bytevalue=0
function calculate(){
var invalue=document.edithub.bytev.value
var selectunit = document.edithub.units.options[document.edithub.units.selectedIndex].value
if (selectunit=="Bytes")
bytevalue=invalue
else if (selectunit=="Kib")
bytevalue=invalue*1024
else if (selectunit=="Mib")
bytevalue=invalue*1024*1024
else if (selectunit=="Gib")
bytevalue=invalue*1024*1024*1024
else if (selectunit=="Tib")
bytevalue=invalue*1024*1024*1024*1024
else if (selectunit=="Pib")
bytevalue=invalue*1024*1024*1024*1024*1024
document.edithub.output.value = bytevalue
}
</script></span></td>
</tr>
i'd be greatful for any help with this. thanks