检查文本框是否为空 [英] Check if textbox has empty value
本文介绍了检查文本框是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
var inp = $("#txt");
if(inp.val() != "")
// do something
是否还有其他方法可以使用变量'inp'检查空文本框
Is there any other way to check for empty textbox using the variable 'inp'
推荐答案
if (inp.val().length > 0) {
// do something
}
如果您想要更复杂的内容,请考虑使用正则表达式或使用验证插件,该插件将这个给你
if you want anything more complicated, consider regex or use the validation plugin which takes care of this for you
这篇关于检查文本框是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文