0

I'm using the following code to see if a form does not contain either class. It works fine if I only look for one, but if I add multiple classes to the if statement, it seems to bypass them.

if (!form.hasClass('no-ajax') || !form.hasClass('register-step')) {

HTML:

<form id="basic-info-form" class="register-step form efocus" method="post" action="form_process.php?source=newUser">

What am I doing wrong?

2 Answers 2

5

The problem is with your if statement. You are saying if the form does NOT have class no-ajax OR has class register-step. So if any of the conditions is true it will go into your if-statement.

you want to make sure it has neither class so it should be && instead of ||

Sign up to request clarification or add additional context in comments.

Comments

0

can you try like

var className = $('.myclass').attr('class');
 if(className.indexOf('myclasscheck') > = 0)

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.