#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,650
    Rep Power
    171

    Character "<" is the first character of a delimiter but occurred as data


    Why do I get html error in sJavascript code?
    Thanks
    javascript Code:
    $("#minus_adults").click(function(){
      var newQty = +($("#qty_adults").val()) - 1;
      if(newQty < 1)newQty = 1;
      $("#qty_adults").val(newQty);
    });

    Code:
     Line 75, Column 13: character "<" is the first character of a delimiter but occurred as data
    
      if(newQty < 1)newQty = 1;
    
    ✉
    
    This message may appear in several cases:
    
        You tried to include the "<" character in your page: you should escape it as "&lt;"
        You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
        Another possibility is that you forgot to close quotes in a previous tag.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1046
    Hi,

    when using XHTML, you can't have a < within inline JavaScript code, because it's always expected to mark the beginning of an HTML tag. This is different from plain HTML, which treats the content of script elements specially.

    There are several solutions: (in this order)

    1. Don't use inline JavaScript
    2. Wrap every inline JavaScript code in a CDATA section
    3. Don't use XHTML
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo