Results 1 to 2 of 2

Thread: Comparison with 0 and JSLint error

  1. #1
    Join Date
    Nov 2009
    Posts
    211
    Thanks
    40
    Thanked 1 Time in 1 Post

    Default Comparison with 0 and JSLint error

    Here's the code:

    Code:
    <input type="number" value="0" id="input">
    <script>
      if (document.getElementById('input').value == 0) {
        alert('Hello, world!');
      }
    </script>
    DEMO

    And here's the JSLint error:

    Expected '===' and instead saw '=='.
    But when I listen to the advice and change == to ===, the alert stops appearing.

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    693
    Thanks
    1
    Thanked 113 Times in 111 Posts

    Default

    Hi there Rain Lover,

    JSLint requires...
    Code:
    
    if (document.getElementById('input').value === '0') 

    coothead

  3. The Following User Says Thank You to coothead For This Useful Post:

    Rain Lover (07-12-2014)

Similar Threads

  1. Two errors I get in JSLint for no good reason
    By Rain Lover in forum JavaScript
    Replies: 1
    Last Post: 03-31-2014, 08:17 PM
  2. Date comparison
    By MSK7 in forum JavaScript
    Replies: 2
    Last Post: 01-02-2010, 11:08 PM
  3. MySQL Comparison
    By jfreak53 in forum PHP
    Replies: 0
    Last Post: 08-22-2009, 09:59 PM
  4. string comparison
    By susapra in forum PHP
    Replies: 1
    Last Post: 09-21-2008, 04:30 AM
  5. New Price comparison site
    By ojsimon in forum The lounge
    Replies: 4
    Last Post: 07-23-2008, 11:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •