#short
#javascript
#html
#jquery
I have this HTML:
input type="text" name="textField" /
input type="submit" value="send" /
How can I do something like this:
When the text field is empty the submit should be disabled (disabled="disabled").
When something is typed in the text field to remove the disabled attribute.
If the text field becomes empty again(the text is deleted) the submit button should be disabled again.
I tried something like this:
$(document).ready(function(){
$('input[type="submit"]').attr('disabled','disabled');
$('input[type="text"]').change(function(){
if($(this).val != ''){
$('input[type="submit"]').removeAttr('disabled');
}
});
});
…but it doesn't work. Any ideas?
On this page of the site you can watch the video online javascript - jQuery disable/enable submit button with a duration of hours minute second in good quality, which was uploaded by the user Code Samples 14 June 2023, share the link with friends and acquaintances, this video has already been watched 211 times on youtube and it was liked by 8 viewers. Enjoy your viewing!