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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:47:22+00:00 2026-06-03T03:47:22+00:00

In my application, I am taking a value for username. If that value is

  • 0

In my application, I am taking a value for username. If that value is 0, then I have to run some code. But how should I write the if block?

 var userName=document.getElementById("member").value;

The above statement will return 0 (zero). Can anybody write the if statement for me? Thank you in advance.This is the entire code

var userName=document.getElementById("member").value;
    var password=document.getElementById("password").value;

    if(userName==="0"){
        var div4 = document.getElementById("errorMessage");
        var text1 = "insert userName.";
        div4.style.display = "block";
        div4.style.color = "red";
        div4.style.fontSize = "65%";
        div4.innerHTML = text1;
  • 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-03T03:47:23+00:00Added an answer on June 3, 2026 at 3:47 am

    Additional to the other answers: you could check for the value 0 this way

    if (Number(userName) === 0)
    

    With the advantage that if the user fills the username field with whitespace only (spaces, tabs etc) it will still evaluate to true (that’s because the Number conversion trims the parameter value).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application with ajax star rating but when i am assigning value
I am writing a .net application that is taking form information to do some
Background: I have am taking over an application (original engineer is leaving) that act
i have mvc application in that i have one form which is taking inputs
I have an application where I am taking a bitmap and compressing it using
I have a spring application that has configured log4j (via xml) and that runs
Right now I have a macro PopulateYearlyValues But it seems to me it's taking
I have a delete statement that's going against one of my core application tables.
I have a query that I'm executing from a .NET application to a SQL
I've traced slugishness in my application to the bit of code that's being timed

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.