HTML CSS Javascript jQuery AJAX PHP Java MORE

How to enable button using Javascript

In this example we will learn how to enable the button when the user put some data in the input field.

bt.disabled = true; Is used to enable a disable button. By default in this example the button is disbaled.

<!DOCTYPE html>
	<input type="text" id="txt" onkeyup="manage(this)" />
	<input type="submit" id="btSubmit" disabled />

	function manage(txt) {
		var bt = document.getElementById('btSubmit');
		if (txt.value != '') {
			bt.disabled = false;
		else {
			bt.disabled = true;



Run it yourself