如何在Jquery中检查textarea是否为空? [英] How to check whether textarea is empty or not in Jquery?
本文介绍了如何在Jquery中检查textarea是否为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的,
我使用以下代码检查textarea是否为空:
Dear all,
I am using following code to check whether textarea is empty or not:
$(function () {
$("#btnSave").click(function () {
var txtaAddress = $("#txtaAddress");
if ( $(txtaAddress.val()).length <1) {
alert('Enter address');
txtaAddress.focus();
return false;
}
});
});
但它不起作用我也尝试过:
but its not working I have also tried:
var txtaAddress = $("#txtaAddress");
if (txtaAddress.val()= "" || txtaAddress.val()= null) {
alert('Enter address');
txtaAddress.focus();
return false;
}
但它也无效。
请帮我摆脱这个问题。
谢谢大家!!
but its also not working.
Please help me to get rid of this problem.
Thank u all!!
推荐答案
(function(){
(function () {
(< span class =code-string> #btnSave)。click(function(){
var txtaAddress =
("#btnSave").click(function () { var txtaAddress =
( #txtaAddress);
if (
这篇关于如何在Jquery中检查textarea是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文