Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7440097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:47:59+00:00 2026-05-29T10:47:59+00:00

In which cases do an input field value equals ” , null or undefined

  • 0

In which cases do an input field value equals '', null or undefined.

I’m trying to check empty fields

if($('#cur').val() == 'undefined' || $('#cur').val() == '' || $('#cur').val() == 'null'){
    alert('Blank');
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:48:00+00:00Added an answer on May 29, 2026 at 10:48 am

    The value of an input element will always be a string. You can safely just compare to the empty string:

    if($("#cur").val() === "") {
        alert("Blank");
    }
    

    You are currently checking for the string literals “undefined” and “null”. That would only be the case if the value of the input was actually the string “undefined” or “null”. For example:

    <!--This would be blank according to your original test-->
    <input type="text" value="undefined">
    

    It may be worth noting that if the input contains blank spaces but nothing else, and you want to count that as empty, the above will not suffice. You can use the jQuery trim function to remove leading/trailing white space from a string:

    if($.trim($("#cur").val()) === "") {
        alert("Blank");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can imagine one case, in which the input parameter could be NULL so
I have a input field in which users specify file size in Mb, so
I have two input fields fromDate and toDate which are instances of Date class.
In which cases would you use which? Is there much of a difference? Which
In which cases, except development, would you prefer XAMPP over a complete installation and
In which cases storing data as XML is preferable to RDBMS and why? Can
what is a difference between System.Windows.Forms.Timer() and System.Windows.Threading.DispatcherTimer() ? In which cases, we should
What is the difference between System.Web.Cache and HTTPContext.Curent.Cache? In which cases both are used?
I know there are many cases which are good cases to use multi-thread in
Are there any cases in which anything more than a linear speed increase comes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.