如果选择文件或textarea包含字母而不是单击按钮,如何自动更改按钮状态? [英] How to automotacially change button status if file selected or textarea contains letters instead for button click?

查看:92
本文介绍了如果选择文件或textarea包含字母而不是单击按钮,如何自动更改按钮状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要实现的是,当我在 textarea 中输入一个字母时,选择类型的图像='file'标签,然后按钮功能或文本应自动更改。



我的问题是,当我自动点击按钮时,更改才会生效。



我尝试过:



JSFiddle

What I want to achieve is, when I enter a letter in the textarea or selecting an image with type='file' tag, then the button functionality or text should change automatically.

My problem is that, the change only will take action when I click on the button instead automatically.

What I have tried:

JSFiddle

推荐答案

您只是在提交点击上运行检查代码,您需要为其他感兴趣的事件运行它,例如textarea或文件更改



You're only running your check code on the submit click, you need to run it for other events you're interested in such as the textarea or file changing


('#form')。submit(function(){
return validate();
});
('#form').submit(function() { return validate(); });


('#txtarea')。keyup(function(){validate();});
('#txtarea').keyup(function(){validate();});


这篇关于如果选择文件或textarea包含字母而不是单击按钮,如何自动更改按钮状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆