SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Noobie if() statement

    I feel kind of silly for not being able to see what's wrong with this, but it's starting to drive me mad.

    So could someone tell me where I'm going wrong?

    PHP Code:
      else if(submit_form.price.value == "" || isNaN(submit_form.price.value)=="true"){
      
    alert"Please enter a price." );
        
    submit_form.price.focus();
        return 
    false;
      } 
    Thanks very much,

  2. #2
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should use single quotes in the alert statement.

  3. #3
    Resident Boozehound simontheak's Avatar
    Join Date
    Jun 2003
    Location
    _root.europe.uk.london
    Posts
    965
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've tried that Curtis, but I'm not having any more luck I'm afraid ...

  4. #4
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    alert(true == "true"); // false
    Can you guess what's wrong?

  5. #5
    SitePoint Evangelist AlienDev's Avatar
    Join Date
    Feb 2007
    Location
    UK
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    else if ((submit_form.price.value == "") || (NaN(submit_form.price.value)=="true")) 
    Try that

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doesn't matter if you use single or double quotes in an alert. Adding more parentheses will also not solve the issue that Sorccu points out.


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
  •