Skip to content Skip to sidebar Skip to footer

Why I Have This Error "starttag: Invalid Element Name"?

I have this function in javascript function validar(e) { const dia = (new Date(e.target.value)).getDay(); if (dia <= 4) { //Cualquier día menor que Viernes e.target

Solution 1:

Your JavaScript contains <=, which is confusing the parsing of the surrounding XML.

Import your JavaScript from an external file to avoid the error. Or, if you really want the JavaScript to be inline, wrap in CDATA so it's not parsed by XML interpreter:

<scripttype="text/javascript">//<![CDATA[functionvalidar(e) {
       const dia = (newDate(e.target.value)).getDay();
       if (dia <= 4) { //Cualquier día menor que Viernes
          e.target.value = ""; //Resetear la fechaalert("Fecha inválida"); //Dar feedback al usuario
       }
    };
//]]></script>

Post a Comment for "Why I Have This Error "starttag: Invalid Element Name"?"