Check if textbox has empty value

后端 未结 8 2032
感情败类
感情败类 2020-11-30 23:19

I have the following code:

var inp = $(\"#txt\");

if(inp.val() != \"\")
// do something

Is there any other way to check for empty textbox

相关标签:
8条回答
  • 2020-11-30 23:58

    Also You can use

    $value = $("#txt").val();
    
    if($value == "")
    {
        //Your Code Here
    }
    else
    {
       //Your code
    }
    

    Try it. It work.

    0 讨论(0)
  • 2020-12-01 00:08

    The check can be done like this:

    if (!!inp.val()) {
    
    }
    

    and even shorter:

    if (inp.val()) {
    
    }
    
    0 讨论(0)
提交回复
热议问题