• 0

[javescript] hidden submit button


Question

how do i make the submit button disabled till a key code is entered

<script>
if ( window.addEventListener ) { 
 var state = 0, hake = [38,38,40,40]; 
 window.addEventListener("keydown", function(e) { 
	if ( e.keyCode == hake[state] ) state++; 
	else state = 0; 
	if ( state == 10 ) 
	///BUTTON///<input type="submit" value="Submit">
	}, true); 
}
</script>

Link to comment
https://www.neowin.net/forum/topic/890050-javescript-hidden-submit-button/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

How about this...

<script>
if ( window.addEventListener ) { 
 var state = 0, hake = [38,38,40,40]; 
 window.addEventListener("keydown", function(e) { 
	    if ( e.keyCode == hake[state] )
                state++; 
	    else
                state = 0;

            //Disable or enable the button based on the state
	    document.getElementById("buttonIDHere").disabled = (state != 10 )
	}, true); 
}
</script>

You'll need to give your button a unique ID to do this so that your javascript can find the correct button. So for your button, you'll need the following syntax...

<input id="buttonIDHere" type="submit" value="Submit" disabled="disabled" />

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Internet Download Manager (IDM) 6.42 Build 42 by Razvan Serea Internet Download Manager (IDM) is a tool to increase download speeds by up to 5 times, resume and schedule downloads. Comprehensive error recovery and resume capability will restart broken or interrupted downloads due to lost connections, network problems, computer shutdowns, or unexpected power outages. IDM integrates seamlessly into Google Chrome, FireFox, Microsoft Edge, Opera, Safari, Internet Explorer, Maxthon and all other popular browsers to automatically handle your downloads. You can also drag and drop files, or use Internet Download Manager from command line. The program supports proxy servers, ftp and http protocols, firewalls, redirects, cookies, authorization, MP3 audio and video content processing. Changes in Internet Download Manager 6.42 Build 42: Updated Chrome extension to support Chrome manifest 3 Fixed bugs Download: Internet Download Manager 6.42 Build 42 | 11.7 MB (Shareware) Links: Internet Download Manager Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • I purchased, and that key is also not working. Well, it worked now.
    • Hello, In the past, I have purchased directly from Amazon, BestBuy, MicroCenter, Microsoft, and Newegg.  When purchasing, I have made sure the seller was either the store in question (not a third-party in their marketplace) or Microsoft. Regards, Aryeh Goretsky  
    • Right. And permission denied means it's still there, now just need to bypass authentication !!
    • Hello, One thing that I noticed is that this TV says it just has "Ethernet" for its LAN. I have a 2019-2020 era Samsung TV, and while I like it, it only shipped with Fast Ethernet (100Mbps), and have to use a USB to Ethernet adapter to get 1GbE speeds. The lack of any mention of what speed Ethernet connection the TV has in its specs on Samsung's website makes me wonder if they are still shipping TVs with only Fast Ethernet support. Regards, Aryeh Goretsky
  • Recent Achievements

    • One Month Later
      TheRingmaster earned a badge
      One Month Later
    • First Post
      smileyhead earned a badge
      First Post
    • One Month Later
      K V earned a badge
      One Month Later
    • Week One Done
      K V earned a badge
      Week One Done
    • Dedicated
      CarlosABC earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      639
    2. 2
      ATLien_0
      241
    3. 3
      Xenon
      175
    4. 4
      neufuse
      155
    5. 5
      +FloatingFatMan
      123
  • Tell a friend

    Love Neowin? Tell a friend!