I want to insert a cookie notification bar. Now on a old Newsletter page I get a error like this:
Uncaught Error: Syntax error, unrecognized expression: li/label
the following code from the newsletter is
if( document.addEventListener ) document.addEventListener( 'DOMContentLoaded', cmxform, false );
function cmxform(){
// Hide forms
$( 'form.cmxform' ).hide().end();
// Processing
$( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
var labelContent = this.innerHTML;
var labelWidth = document.defaultView.getComputedStyle( this, '' ).getPropertyValue( 'width' );
var labelSpan = document.createElement( 'span' );
labelSpan.style.display = 'block';
labelSpan.style.width = labelWidth;
labelSpan.innerHTML = labelContent;
this.style.display = '-moz-inline-box';
this.innerHTML = null;
this.appendChild( labelSpan );
} ).end();
// Show forms
$( 'form.cmxform' ).show().end();
}
//function to check empty fields
function isEmpty(strfield1, strfield2) {
strfield1 = document.forms.newsletter_subscribe.nome.value
strfield2 = document.forms.newsletter_subscribe.email.value
if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
{
alert("Please insert your name!")
return false;
}
if (strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ')
{
alert("Please insert a valid Email!")
return false;
}
return true;
}
//function to check valid email address
function isValidEmail(){
validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
strEmail = document.forms.newsletter_subscribe.email.value;
// search email text for regular exp matches
if (strEmail.search(validRegExp) == -1)
{
alert('Email not valid! Please retry!');
return false;
}
return true;
}
//function to check privacy
function Privacy()
{
if (document.forms.newsletter_subscribe.checkbox.checked==false)
{
alert('Please accept the privacy conditions!');
return false;
}
return true;
}
//function that performs all functions, defined in the onsubmit event handler
function check(){
if (isEmpty()){
if (isValidEmail()){
if (Privacy()) {
return true;
}
}
}
return false;
}
//**********************************************************************************************
//function to check empty fields unsubscribe form
function isEmptyEmail(strfield1) {
strfield1 = document.forms.newsletter_unsubscribe.email.value
if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
{
alert("Please insert a valid Email!")
return false;
}
return true;
}
//function to check valid email address
function isValidEmailCancel(){
validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
strEmail = document.forms.newsletter_unsubscribe.email.value;
// search email text for regular exp matches
if (strEmail.search(validRegExp) == -1)
{
alert('Email not valid! Please retry!');
return false;
}
return true;
}
//function that performs all functions, defined in the onsubmit event handler
function check_unsubscribe(){
if (isEmptyEmail()){
if (isValidEmailCancel()){
return true;
}
}
return false;
}
When delete the new resource, that newsletter script is ok. But, when use the new jQuery resource get this failure.
If you want to concatenate more than one selector in jQuery find you are using the wrong syntax
$( 'form.cmxform' ).find( 'li/label' ).not( '.nocmx' ).each( function( i ){
should become:
$( 'form.cmxform' ).find( 'li, label' ).not( '.nocmx' ).each( function( i ){
and this means you are looking for any li OR label tag in the DOM scope you have selected ('form.cmxform')