Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Enable/Disable Button through javascript [modified]

Enable/Disable Button through javascript [modified]

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascriptasp-nettesting
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xfitr2
    wrote on last edited by
    #1

    I have a asp.net page where my button is enabled or disabled depending on whether two textboxes are properly filled out. I enable/disable the button through the onchange events of the textboxes. Once button is enabled and I click it, the postback seems to have disappeared because it does nothing. I enable/disable the button like this:

    	function checkBuild() {
    		document.getElementById('sMsg').innerHTML = '';
    		checkBAL();
    		checkINI();
    		if ((checkBAL()) && (checkINI())) {
    			**document.form1.btn1.disabled = false;**
    			checkWarning();
    		} else {
    			**document.form1.btn1.disabled = true;**
    		}
    	}
    

    I've read that in order for the button "btn1" to postback, I must have it enabled onLoad which I have done for testing. Therefore, if I click the button before my javascript fires, it works; only stops working once my checkBuild() function is called by the textboxes javascript onchange event. Can anyone help with this issue? Many thanks.

    modified on Monday, September 22, 2008 10:31 PM

    T 1 Reply Last reply
    0
    • X xfitr2

      I have a asp.net page where my button is enabled or disabled depending on whether two textboxes are properly filled out. I enable/disable the button through the onchange events of the textboxes. Once button is enabled and I click it, the postback seems to have disappeared because it does nothing. I enable/disable the button like this:

      	function checkBuild() {
      		document.getElementById('sMsg').innerHTML = '';
      		checkBAL();
      		checkINI();
      		if ((checkBAL()) && (checkINI())) {
      			**document.form1.btn1.disabled = false;**
      			checkWarning();
      		} else {
      			**document.form1.btn1.disabled = true;**
      		}
      	}
      

      I've read that in order for the button "btn1" to postback, I must have it enabled onLoad which I have done for testing. Therefore, if I click the button before my javascript fires, it works; only stops working once my checkBuild() function is called by the textboxes javascript onchange event. Can anyone help with this issue? Many thanks.

      modified on Monday, September 22, 2008 10:31 PM

      T Offline
      T Offline
      Tamer Oz
      wrote on last edited by
      #2

      Call the javascript function on the bottom of the page.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups