0

for some reason in this code I am getting an error message $('#emailError').css({'display': 'block', 'background-color': #e35152});

Uncaught SyntaxError: Unexpected token ILLEGAL

I don't know why

here is all the javascript.

function confirmEmail() {
        var email      = document.getElementById('email').value;
        var confirmail = document.getElementById('emailConfirm').value;
        if (email != confirmail) {
            $('#emailError').css({'display': 'block', 'background-color': #e35152});
             //document.getElementById('emailError').style.display = "block";
             //document.getElementById('emailError').style.background ='#e35152';
        };
    };

here is my html

     <div class="form-group">
         <label>Email *</label>
         <input type="email" name="email" class="form-control" required="required">
    </div>
    <div class="form-group">
       <label>Confirm Email *</label>
       <input type="email" name="emailConfirm" class="form-control" required="required" onblur="confirmEmail()">
       <span id="emailError" style="display: none;">Your emails must match</span>
    </div>
5
  • 3
    You need to put quotes around #e35152 Commented Jan 21, 2016 at 22:52
  • @MikeC thanks though its still not working trying to get a span to show onblurr an error message if not same email and confirm email any ideas Commented Jan 21, 2016 at 22:57
  • I guarantee you if you put quotes around it like what @kpucha suggests it will fix that specific problem. If you're having additional problems, try debugging it yourself then asking a new question on Stack Overflow if you're still having trouble with a specific issue. Commented Jan 21, 2016 at 22:59
  • jsfiddle.net/6u7yLgza/1 sorry here it is updated Commented Jan 21, 2016 at 23:00
  • Your inputs doesn't have ID so if you try to get an element with document.getElementById() you need to set the attribute id in the elements id="email" id="emailConfirm" Commented Jan 21, 2016 at 23:20

1 Answer 1

5

You miss the '' in the color:

//$('#emailError').css({'display': 'block', 'background-color': #e35152});
$('#emailError').css({'display': 'block', 'background-color': '#e35152'});
                                                              ^here & ^here
Sign up to request clarification or add additional context in comments.

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.