Skip to content

Instantly share code, notes, and snippets.

@kdabir
Created November 19, 2012 12:36
Show Gist options
  • Save kdabir/4110429 to your computer and use it in GitHub Desktop.
Save kdabir/4110429 to your computer and use it in GitHub Desktop.
disable submit if text field is empty using javascript and jquery
var changeHandler = function (e) {
console.log ($.trim(this.value));
if ($.trim(this.value)){
$("input[type=submit]").removeAttr("disabled");
} else {
$("input[type=submit]").attr("disabled", "disabled");
}
};
$("input[type=text]").keyup(
changeHandler
)​
@md-riaz
Copy link

md-riaz commented Jul 31, 2019

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment