0

Hello I am using this function code below to automatic add a colon(:) after I entered two numbers in a textbox

    function limit(){    
    if (document.getElementById('FitaCorrectionIn1').value.length == 2) {
                document.getElementById('FitaCorrectionIn1').value += ":";
                return false;
            }
return false
    }

And here for the max length of 5

 <input id="ID" type="text" style="width: 100px" onkeydown="limit()"
                            maxlength="5" />

And for my problem # 1 is after the textbox filled with time for example 10:00 I can manage to erase the 00 using the backspace and my problem is I want to erase also the added colon using the backspace is there any way to solve this?.

For the problem # 2 is for example I want enter a time of 1:00 but the output is 1::00 I need to have a condition for this or any way to solve?.

  • Why are you not just using a jquery masked input plugin? (for example - [jquery.inputmask](https://github.com/RobinHerbots/jquery.inputmask)) –  Aug 18 '16 at 01:38
  • @StephenMuecke Can you give me an example?. I'm just starting to learn –  Aug 18 '16 at 01:40
  • See edited comment –  Aug 18 '16 at 01:41
  • @StephenMuecke Do I need to Download the js from the site?. –  Aug 18 '16 at 02:03
  • Download it using the Nuget Package Manager –  Aug 18 '16 at 02:06
  • after i download it from nuget i get the ff. `inputmask.extensions.js / inputmask.date.extensions.js / inputmask.js / inputmask.numeric.extensions.js / inputmask.phone.extensions.js / inputmask.regex.extensions.js / jquery.inputmask.js.` and i try to drag the `inputmask.js , jquery.inputmask.js` to my .cshtml but now working or i am doing wrong?. –  Aug 18 '16 at 02:16
  • Read the documentation on the site :) –  Aug 18 '16 at 02:16

0 Answers0