javascript - How do I input a number / time of 01:10 from my code? -
i have working code below input number/tme
in textbox. code below functioning want set textbox value 00:00
, edit function
code second jsfiddle
edited code not going idea. in second jsfiddle want input time of 05:30
code replacing number input user textbox 0
function maskedtextboxdpsdeparture() { var mymask = "__:__"; var mycorrectionout2 = document.getelementbyid("departure"); var mytext = ""; var mynumbers = []; var myoutput = "" var thelastpos = 1; mytext = mycorrectionout2.value; //get numbers (var = 0; < mytext.length; i++) { if (!isnan(mytext.charat(i)) && mytext.charat(i) != " ") { mynumbers.push(mytext.charat(i)); } } //write on mask (var j = 0; j < mymask.length; j++) { if (mymask.charat(j) == "_") { //replace "_" number if (mynumbers.length == 0) myoutput = myoutput + mymask.charat(j); else { myoutput = myoutput + mynumbers.shift(); thelastpos = j + 1; //set current position } } else { myoutput = myoutput + mymask.charat(j); } } document.getelementbyid("departure").value = myoutput; document.getelementbyid("departure").setselectionrange(thelastpos, thelastpos); } document.getelementbyid("departure").onkeyup = maskedtextboxdpsdeparture;
html
< input id="departure" type="text" style="width: 35px; text-align: center" value="__:__" />
any suggestion accepted. thanks.
Comments
Post a Comment