0

I get "uncaught syntax error unexpected identifier"

I can't seem to find the syntax error. Im using the same code from an Lynda.com tutorial and it worked for him. Alas I hand typed the text, but it looks the exact same.

$(".member-form").submit(function() {
              var abort = false;
              $("div.error")remove();
              $(':input[required]')each(function() {
                  if ($(this).val()=== '') {
                      $(this).after('div class="error">This is a required field</div>');
                      abort = true;
                  }

              });  //go through each required value
              if (abort) { return false;} else {return true;}
          }); //on submit

any help appreciated as I just dont see anything wrong above

0

2 Answers 2

2

missing period before remove()

$("div.error").remove(); 
//            ^ add period

and each()

$(':input[required]').each(
//                   ^ add period
Sign up to request clarification or add additional context in comments.

Comments

0

as soon as I posted I reviewed the code I hand copied, to recheck, and I see that there is no dot. before remove. And then did a face palm. Solved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.