is easy enough.
But how did you get the HH:MM in the first place?? Is it just coming from some form field?
<input name="time" onChange="convertTime(this);">
function convertTime( what )
var re = /^\d\d?\:\d\d$/;
if ( re.test(what.value) )
var temp = val.split(":");
hours = parseFloat( temp );
mins = parseFloat( temp );
what.value = hours + mins/60.0;
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.