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 8529799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:06:41+00:00 2026-06-11T09:06:41+00:00

Possible Duplicate: Check if inputs are empty using jQuery I have form and textboxes,

  • 0

Possible Duplicate:
Check if inputs are empty using jQuery

I have form and textboxes, how will I determine if any of these textboxes is empty using javascript if else statement once a form button is clicked.

function checking() {
    var textBox = $('input:text').value;
    if (textBox == "") {
        $("#error").show('slow');
    }
}

Thanks in advance!

  • 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-06-11T09:06:42+00:00Added an answer on June 11, 2026 at 9:06 am

    By using jQuery selectors for selecting the elements, you have a jQuery object and you should use val() method for getting/setting value of input elements.

    Also note that :text selector is deprecated and it would be better to trim the text for removing whitespace characters. you can use $.trim utility function.

    function checking() {
        var textBox =  $.trim( $('input[type=text]').val() )
        if (textBox == "") {
            $("#error").show('slow');
        }
    }
    

    If you want to use value property you should first convert the jQuery object to a raw DOM object. You can use [index] or get method.

     var textBox = $('input[type=text]')[0].value;
    

    If you have multiple inputs you should loop through them.

    function checking() {
        var empty = 0;
        $('input[type=text]').each(function(){
           if (this.value == "") {
               empty++;
               $("#error").show('slow');
           } 
        })
       alert(empty + ' empty input(s)')
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Check if a variable is empty Simple PHP question: I have this
Possible Duplicate: How can you check for a #hash in a URL using JavaScript?
Possible Duplicate: How can you check for a #hash in a URL using JavaScript?
Possible Duplicate: Check of specific radio button is checked I have these 2 radio
Possible Duplicate: Check checkbox checked property using jQuery I am having an issue picking
Possible Duplicate: How do I check a checkbox with JQuery or Javascript? I'm trying
Possible Duplicate: Check whether $_POST-value is empty I am using this code to validate
Possible Duplicate: Check synchronously if file/directory exists in Node.js For example, i have a
Possible Duplicate: How to check if resultset has one row or more? What will
Possible Duplicate: How to check file types of uploaded files in PHP? I have

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.