HTML Standards Questions


The code that is causing the alert is "
<script type="text/javascript">
//<[CDATA[
function searchProduct(){
  var search_var = document.searchform.searchvalue.value;
  if (!isEmpty(search_var) && search_var != 'Product ID or Keyword') {
	  document.searchform.submit();
  }
}
//]]>
</script>

Open in new window


I receive these three messages...

Line 34, Column 3: character "<" is the first character of a delimiter but occurred as data
//<[CDATA[
¿
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.
 Line 37, Column 28: character "&" is the first character of a delimiter but occurred as data
  if (!isEmpty(search_var) && search_var != 'Product ID or Keyword') {
¿
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.
 Line 37, Column 29: character "&" is the first character of a delimiter but occurred as data
  if (!isEmpty(search_var) && search_var != 'Product ID or Keyword') {
¿
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.
 Line 41, Column 3: marked section end not in marked section declaration
//]]>

How can I address this properly.
cstormerAsked:
Who is Participating?
 
nap0leonCommented:
Try this:

<script type="text/javascript">
function searchProduct(){
  var search_var = document.searchform.searchvalue.value;
  if (!(isEmpty(search_var)) && !(search_var == 'Product ID or Keyword')) {
	  document.searchform.submit();
  }
}
</script>

Open in new window

0
 
nap0leonCommented:
Looking at the line numbers, the errors are coming from your CDATA tags.  even though you have the lines commented, they still are not valid.  You may be OK with just removing them rather than using the adjusted "if" statement I posted.
0
 
cstormerAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.