i have this code, it's purpose is to automatically add a colon when the index is 2,
i have done it, but when replacing(overwrite) index 2 where (:) is, you can replace it with a different char, so basically colon will be removed.
and also what if the user has entered a single digit, what do you suggest about that?
i also need to add their values to get the total time, i'm still working on that but if you have any idea, that would be of big help, thanx
<html>
<FORM>
<table border="1">
<tr><th>Time</th>
<td><input type="text" name="alpha" value="" onkeypress="addColon(this.form.alpha, this.form.total);" maxlength="5"/></td>
<td><input type="text" name="beta" value="" onkeypress="addColon(this.form.beta, this.form.total);" maxlength="5"/></td>
<td><input type="text" name="gamma" value="" onkeypress="addColon(this.form.gamma, this.form.total);" maxlength="5"/></td>
<td><input type="text" name="total" value="" disabled="disable"/></td>
</tr>
</table>
<input type="text" name="displaycount" size="20">
</FORM>
<SCRIPT TYPE="text/javascript">
function addColon(what, outTo){
var string = what.value;
var i = string.indexOf(":");
//alert(what.value.length);
if(what.value.length ==2 && i < 0){
what.value = what.value + ':';
}
//add condition
//alert(what.value);
outTo.value = what.value
}
function addColumns(){}
</SCRIPT>
</html>
`