I want to grey out these two things the song input field and the submit button until the user enters and artist. Is there an easy way to do this via JQuery.
the id of the artist input field is #request_artist
1.1 To disable a submit button, you just need to add a disabled attribute to the submit button. $("#btnSubmit"). attr("disabled", true); 1.2 To enable a disabled button, set the disabled attribute to false, or remove the disabled attribute.
Just click f12 in your browser, find the submit button in the html, and then remove the disabled ! It will submit the form even if the inputs are empty.
If you want to grey out, u can use the above one: document. myForm. myField.
You can do something like this:
var artist = ('#request_artist');
var song = ('#request_song');
var assubmit = ('#request_submit');
song.attr('disabled', true);
assubmit.attr('disabled', true);
artist.change(function() {
if(artist.val() > 0) {
song.attr('disabled', false);
assubmit.attr('disabled', false);
} else {
song.attr('disabled', true);
assubmit.attr('disabled', true);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With