#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?
На этой странице сайта вы можете посмотреть видео онлайн javascript - jQuery disable/enable submit button длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Code Samples 14 Июнь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 211 раз и оно понравилось 8 зрителям. Приятного просмотра!