Introduction:
Here
I will explain how to enable or disable a button control in JavaScript or Enable/Disable a controls in JavaScript.
Description:
In previous articles I explained JavaScript Enable/Disable button based on text in textboxes, jQuery Shake image on mouse over, jQuery upload multiple files using multiple file upload plugin, jQuery fancy switch on and off effects example and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to enable or disable a button control in JavaScript.
In previous articles I explained JavaScript Enable/Disable button based on text in textboxes, jQuery Shake image on mouse over, jQuery upload multiple files using multiple file upload plugin, jQuery fancy switch on and off effects example and many articles relating to JavaScript, jQuery, asp.net. Now I will explain how to enable or disable a button control in JavaScript.
|
|
If you want to see it in complete example check this code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Enable
or Disable a control in javascript</title>
<script language="javascript"
type="text/javascript">
//function to enable button if
two textboxes contains text
function SetButtonStatus() {
var txt = document.getElementById('txtfirst');
//Condition to check whether
user enters text in two textboxes or not
if (txt.value.length >= 1)
document.getElementById('btnButton').disabled = false;
else
document.getElementById('btnButton').disabled = true;
}
</script>
</head>
<body>
<div>
<input type="text"
id="txtfirst"
onkeyup="SetButtonStatus(this,'btnButton')"/>
<input type="button"
id="btnButton"
value="Button"
disabled="disabled"
/>
</div>
</body>
</html>
|
Live
Demo
For
live demo enter text in textbox whenever we enter text button will enable
otherwise it’s in disable mode
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
2 comments :
Wow ..Super Bhai.. Really helpful.
great
Note: Only a member of this blog may post a comment.