JS is easy enough.
But how did you get the HH:MM in the first place?? Is it just coming from some form field?
<form>
<input name="time" onChange="convertTime(this);">
</form>
<script>
function convertTime( what )
{
var re = /^\d\d?\:\d\d$/;
if ( re.test(what.value) )
{
var temp = val.split(":");
hours = parseFloat( temp[0] );
mins = parseFloat( temp[1] );
what.value = hours + mins/60.0;
}
}
</script>
That won't change the value entered unless it conforms to the regexp pattern given. Either h:mm or hh:mm
If you want to allow other patterns, you have to say so.