Need to write code on key press event in asp.netselvi subramanian11yAsked Jul 19, 2015, 11:30 PM EDT7 answersShareLinkedInXCopy linkSavei focus in textbox1 if i press enter key for 2 times i need to focus on textbox2 using key press event in asp.net
Need to write code on key press event in asp.netselvi subramanian11yAsked Jul 19, 2015, 11:30 PM EDT7 answersShareLinkedInXCopy linkSavei focus in textbox1 if i press enter key for 2 times i need to focus on textbox2 using key press event in asp.net
Raja TRank #685 · 3.5K reputation11y agoPosted Jul 19, 2015, 11:47 PM EDT0Hi, try this function runScript(e) { if (e.keyCode == 13) { alert('enter pressed'); return false; } } 0Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 19, 2015, 11:54 PM EDT0Hi Selvi, Please see below code: A function is triggered when the user is pressing a key in the input field. // Declare Global variable var checkVal = 0; var myFunction = function(e){ if(e.keyCode == 13){ checkVal = checkVal + 1; }else{ checkVal = 0; } // Checking value for second time Enter key press if(checkVal == 2){ document.getElementById("txtTest2").focus(); }}0selvi subramanianRank #2,007 · 723 reputation11y agoPosted Jul 20, 2015, 2:02 AM EDT0code is not working0Raja TRank #685 · 3.5K reputation11y agoPosted Jul 20, 2015, 2:06 AM EDT0Hi, Which code you are trying show me? If you have any issue please describe it more. ?0Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 20, 2015, 2:14 AM EDT0As per Raja comment which code you tried. Did you try whatever I provided? If yes then please provide which browser and what error you are getting? 0selvi subramanianRank #2,007 · 723 reputation11y agoPosted Jul 21, 2015, 1:08 AM EDT0both of ur code its not working in chrome0Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 21, 2015, 1:20 AM EDT0Hi Selvi, Just small change in code. Please try again.I assume that double press on textbox1 it will go textbox2. A function is triggered when the user is pressing a key in the input field. // Declare Global variable var checkVal = 0; var myFunction = function(e){ if(e.keyCode == 13){ checkVal = checkVal + 1; }else{ checkVal = 0; } // Checking value for second time Enter key press if(checkVal == 2){ document.getElementById("txtTest2").focus(); checkVal = 0; }} This time it will work. 0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 19, 2015, 11:54 PM EDT0Hi Selvi, Please see below code: A function is triggered when the user is pressing a key in the input field. // Declare Global variable var checkVal = 0; var myFunction = function(e){ if(e.keyCode == 13){ checkVal = checkVal + 1; }else{ checkVal = 0; } // Checking value for second time Enter key press if(checkVal == 2){ document.getElementById("txtTest2").focus(); }}0selvi subramanianRank #2,007 · 723 reputation11y agoPosted Jul 20, 2015, 2:02 AM EDT0code is not working0Raja TRank #685 · 3.5K reputation11y agoPosted Jul 20, 2015, 2:06 AM EDT0Hi, Which code you are trying show me? If you have any issue please describe it more. ?0Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 20, 2015, 2:14 AM EDT0As per Raja comment which code you tried. Did you try whatever I provided? If yes then please provide which browser and what error you are getting? 0selvi subramanianRank #2,007 · 723 reputation11y agoPosted Jul 21, 2015, 1:08 AM EDT0both of ur code its not working in chrome0Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 21, 2015, 1:20 AM EDT0Hi Selvi, Just small change in code. Please try again.I assume that double press on textbox1 it will go textbox2. A function is triggered when the user is pressing a key in the input field. // Declare Global variable var checkVal = 0; var myFunction = function(e){ if(e.keyCode == 13){ checkVal = checkVal + 1; }else{ checkVal = 0; } // Checking value for second time Enter key press if(checkVal == 2){ document.getElementById("txtTest2").focus(); checkVal = 0; }} This time it will work. 0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
selvi subramanianRank #2,007 · 723 reputation11y agoPosted Jul 20, 2015, 2:02 AM EDT0code is not working0
Raja TRank #685 · 3.5K reputation11y agoPosted Jul 20, 2015, 2:06 AM EDT0Hi, Which code you are trying show me? If you have any issue please describe it more. ?0
Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 20, 2015, 2:14 AM EDT0As per Raja comment which code you tried. Did you try whatever I provided? If yes then please provide which browser and what error you are getting? 0
selvi subramanianRank #2,007 · 723 reputation11y agoPosted Jul 21, 2015, 1:08 AM EDT0both of ur code its not working in chrome0
Manas MohapatraRank #182 · 13.2K reputation11y agoPosted Jul 21, 2015, 1:20 AM EDT0Hi Selvi, Just small change in code. Please try again.I assume that double press on textbox1 it will go textbox2. A function is triggered when the user is pressing a key in the input field. // Declare Global variable var checkVal = 0; var myFunction = function(e){ if(e.keyCode == 13){ checkVal = checkVal + 1; }else{ checkVal = 0; } // Checking value for second time Enter key press if(checkVal == 2){ document.getElementById("txtTest2").focus(); checkVal = 0; }} This time it will work. 0
Raja TRank #685 · 3.5K reputationPosted Jul 19, 2015, 11:47 PM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Jul 19, 2015, 11:54 PM EDT
A function is triggered when the user is pressing a key in the input field.
selvi subramanianRank #2,007 · 723 reputationPosted Jul 20, 2015, 2:02 AM EDT
Raja TRank #685 · 3.5K reputationPosted Jul 20, 2015, 2:06 AM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Jul 20, 2015, 2:14 AM EDT
selvi subramanianRank #2,007 · 723 reputationPosted Jul 21, 2015, 1:08 AM EDT
Manas MohapatraRank #182 · 13.2K reputationPosted Jul 21, 2015, 1:20 AM EDT
A function is triggered when the user is pressing a key in the input field.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts